View Single Post
  #8 (permalink)  
Old April 30th, 2008, 02:46 PM
dparsons dparsons is offline
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

This is where it gets a bit more tricky. If you simply put this code on your page:

For x = 1 to Request.Form.Count
    'This is the form control name
    Response.Write Request.Form.Key(x) & " = "
    'This is the form control value
    Response.Write Request.Form.Item(x) & "<br>"
Next

and run it you will see a print out to the screen something like

Checkbox1 = <value>
Checkbox2 =
Checkbox3 = <value>
etc

You should try this out anyway just to see how the code works. In so far as getting specific values, that is where it gets complex. Since you are naming the activity checkboxes dynamically based on data from the database you will need to use some form of loop. If you appened cbAct_, for example, to each of your checkboxes (so that when the checkbox was rendered the name would be cbAct_MyActivity) you could do a bit of string checking:

For x = 1 to Request.Form.Count
    If InStr(Request.Form.Key(x), 'cbAct_') > 0 Then
        Response.Write Request.Form.Key(x) & " = "
        'This is the form control value
        Response.Write Request.Form.Item(x) & "<br>"
    End If
Next
This code looks for the exsitance of the characters cbAct_ at the beginning of each of the form field names, if it is found you can assume that it is your activity and write the data out ot the screen, if the characters aren't found you will do nothing.

Finally, you could also do something like this:

    Set MyConn=Server.CreateObject("ADODB.Connection")
    MyConn.Open "pqrtrav"
    Set Rs=MyConn.Execute("SELECT*From[trip]Order by activity")
    Previousactivity="None"
    WHILE NOT Rs.EOF
     Response.Write Request.Form(rs("Activity"))
    Wend
I think that a second call to the database here is a bit of overkill but either method will work.

hth.
-Doug


================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
Reply With Quote