Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Write HTML Table data db

    This might be difficult. I wrote some .asp code to dynamically generate an HTML table with input boxes for n number of rows via a textbox. You click on the submit button and get a new .asp page with the table ready for input. Now, what I want to do is write each row to a Access table.

    Here's the skinny: specify the number of Recipients (ie number of rows) - this goes to .asp code that generates a table whose items i can list out like so:

    <font color=448800>
    1 RecipientAge1 = 1
    2 RecipientGender1 = Male
    3 Ethnicity1 = Black
    4 InsuranceStatus1 = Medicaid
    5 RecipientAge2 = 2
    6 RecipientGender2 = Female
    7 Ethnicity2 = White
    8 InsuranceStatus2 = Medicare
    </font color=448800>

    There are, in this case, 2 rows and the <font color=448800>Name</font color=448800> in the first column and the <font color=448800>Value</font color=448800> in the second. the names increment based on 0 to N from the input box on the referring form. If I take out the increment then I get a single <font color=448800>Name</font color=448800> with multiple values, comma-seperated. From there I get puzzled. It's not obvious to me how you could 'page thru' each rown and assign values to a table in Access -- I could just run a insert the table in question but in order to make sure the hidden field names match I'd end up with comma-seperate values in one row (sets of values for each column) rather than multiple rows.

    Any suggestions??

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Write HTML Table data db

    Hi Steve,

    As with most issues, there are many ways to attack this one. I would stay away from Comma-separated values here. I think you can do it much easier by simply passing form variables and working with code loops. Here's the basic idea:

    Page 1) Receive the number of rows from the user (let's call it lngRows)
    Page 2) Create a table based on the desired number of rows (using a code loop). Since you only plan to collect 4 fields (columns), I would suggest using numbers for the fields (1-4) and numbers for the rows. I typically use an object name like 1_1 (field_row). That makes it easy when processing the items in the last page. Let's say your user enters 3 for the number of rows. (Be sure to pass lngRows as a hidden form variable.) Your text boxes should be generated like so:
    <table cellspacing=3 cellpadding=3 border=1><td>Recipient Age</td><td>Recipient Gender</td><td>Ethnicity</td><td>Insurance Status</td><td>1. (1_1)</td><td>(1_2)</td><td>(1_3)</td><td>(1_4)</td><td>2. (2_1)</td><td>(2_2)</td><td>(2_3)</td><td>(2_4)</td><td>3. (3_1)</td><td>(3_2)</td><td>(3_3)</td><td>(3_4)</td><td>4. (4_1)</td><td>(4_2)</td><td>(4_3)</td><td>(4_4)</td></table>
    Page 3) Here's where it gets fun. Grab the lngRows variable which should be passed through the form. You'll want to use a loop to collect the values as such:
    (assume rst is the opened recordset object and lngRows is the row count)

    Dim X
    For X = 1 to lngRows
    rst.AddNew
    rst("RecipientAge") = Request.Form(X & "_1")
    rst("RecipientGender") = Request.Form(X & "_2")
    rst("Ethnicity") = Request.Form(X & "_3")
    rst("InsuranceStatus") = Request.Form(X & "_4")
    rst.Update
    Next

    rst.Close
    set rst = nothing

    Hope this helps!

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Write HTML Table data db

    worked perfectly! thanks. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

    don't know why but i do enjoy this sort of thing. must have gotten dropped on my head when young... <img src=/S/bash.gif border=0 alt=bash width=35 height=39>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •