How do I retreive my second value?

Posted on 2012-08-23
Last Modified: 2012-08-28
Hi experts,

In my script I construct a part of a form based on some fields from my database:

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT MSVT_handelingen.*, MSVT_categorieen.categorie AS categorienaam, MSVT_categorieen.complexiteit FROM MSVT_handelingen INNER JOIN MSVT_categorieen ON MSVT_handelingen.categorie=MSVT_categorieen.ID", CS, 3, 4
         While Not rs.EOF
                  Response.Write "<tr><td align=""center""><input type=""checkbox"" value=""" & rs("volgorde") & """ name=""checkbox"" /></td><td align=""center"">"& rs("volgnummer") & "</td><td>" & rs("handeling") & "</td><td align=""center"">"& rs("normtijd")&"</td><td align=""center""><input size=""5"" type=text name=""tijd-"& rs("volgorde") &"""></td></tr>"& vbCrLf
Set rs = Nothing

This resulds in html output like this:
<tr><td align="center"><input type="checkbox" value="1" name="checkbox" /></td><td align="center">1</td><td>inzetten/starten medicatietoediening via een pomp (morfine, dormicum)</td><td align="center">60</td><td align="center"><input size="5" type=text name="tijd-1"></td></tr>
<tr><td align="center"><input type="checkbox" value="2" name="checkbox" /></td><td align="center">2</td><td>het toedienen of aansluiten van intraveneuze medicatie</td><td align="center">30</td><td align="center"><input size="5" type=text name="tijd-2"></td></tr>
<tr><td align="center"><input type="checkbox" value="3" name="checkbox" /></td><td align="center">3</td><td>toedienen te prepareren medicatie via rechtstreekse intraveneuze injectie of via een lopend infuus</td><td align="center">20</td><td align="center"><input size="5" type=text name="tijd-3"></td></tr>
<tr><td align="center"><input type="checkbox" value="4" name="checkbox" /></td><td align="center">4</td><td>inbrengen  perifere catheter</td><td align="center">30</td><td align="center"><input size="5" type=text name="tijd-4"></td></tr>
<tr><td align="center"><input type="checkbox" value="5" name="checkbox" /></td><td align="center">5</td><td>aanwezigheid gedurende de toediening van medicatie, bv antibiotica of chemo en aansluiten en afkoppelen </td><td align="center">60-180</td><td align="center"><input size="5" type=text name="tijd-5"></td></tr>

As you can see I have selectbox and a text input in every line.

I know the way to retreive how many boxes are checked and can indentify them with this sniplet:

response.write "Number of boxes checked: "&chkCnt&"<BR>"
if chkCnt > 0 then
  do while i <=chkCnt
    response.write "Boxnumber " & request.form("checkbox")(i) & " is checked." &"<BR>"
end if

But how can I catch the given value in the text input?

in this script?

Question by:Steynsk
    LVL 52

    Expert Comment

    by:Scott Fell, EE MVE
    Let's say you have 8 checkbox's on your form.  Each checkbox has the same name. In your example, you named it, "checkbox".  Now lets assume each check box has a given value 1 through 8 where the first checkbox is 1...and the last is 8.  

    Now you need to catch and maybe store the values of the checkex box's.  

    First the checked value of the box's with the same name (or any form fields with the same name) is a comma separated list.  So if box's 1, 3 and 5 are checked and you simply looked at your submitted data via response.write request.form("checkbox") you would see, "1,3,5".

    First to store this data, it is very common to simply store the data to a text field in the database.  Just make it long enough to handle all the values if checked.

    Next you need to parse out the checked or saved value.  Since it is a comma separated list, we just need to turn it into an array and loop through it.

    Assuming form submitted:
    arrCheckbox=split(strCheckbox,",") ' split based on the comma
    'now loop through the result
    For each x in arrCheckbox
      response.write x
    ' maybe you need to see if checkbox 5 is checked
    for each x in arrCheckbox
         if cstr(x)="5" then
                   response.write "Found a match"
        end if
    ' another option is instr
    if instr(1,strCheckbox,"5",1 )> 0 then ' notice here I used strCheckbox and not arrCheckbox
                   response.write "Found a match"
    end if

    Open in new window

    I think the first way can be more accurate.
    LVL 1

    Author Comment

    Thanks Padas,

    But the part you try to explain has been solved as you can see in the last part of the question.

    I need to capture the text input part of form.
    LVL 1

    Accepted Solution

    I solved my own question:

    if chkCnt > 0 then
      do while i <=chkCnt
       volgnummer = request.form("checkbox")(i)
       tijd = "tijd-" & volgnummer
        response.write "volgnummer " & request.form("checkbox")(i) & " is aangevinkt met waarde " & request.form(tijd) & "<BR>"
    end if
    LVL 1

    Author Closing Comment

    I solved my own question

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now