[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


How do I retreive my second value?

Posted on 2012-08-23
Medium Priority
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
  • 3
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 38325330
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.

Author Comment

ID: 38328188
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.

Accepted Solution

Steynsk earned 0 total points
ID: 38328228
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

Author Closing Comment

ID: 38340173
I solved my own question

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Loops Section Overview
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month18 days, 15 hours left to enroll

834 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