Passing with checkboxes.

R

Renie83

What I have are two pages. One is a form with some input boxes and
check boxes on it. It is posting to a different script page that
inserts into a database and sends the fields through email. My problem
is sending the information which is checked through to the next page.
Each of my checkboxes is given the value of what should be inserted in
the table and into the email. I just need a way of determining which
checkbox is checked so I can send my information.
Thanks a bunch!
Renie83
 
R

Ray at

If the checkbox is not checked, it will not return a value:

<form method="post" action="someotherpage.asp">
<input type="checkbox" name="checkbox1" value="This is checkbox number one."
checked>
<input type="checkbox" name="checkbox2" value="This is the second
checkbox.">
<input type="submit">
</form>

post to:

Response.Write Request.Form("checkbox1") & "<hr>"
Response.Write Request.Form("checkbox2")


There will be no value for checkbox2, because it was not checked.

You could also use some logic like:
bCheckbox2WasChecked = Len(Request.Form("checkbox2")) > 0
Response.write bCheckbox2WasChecked

Ray at work
 
A

Adrian Forbes - MVP

Easiest way is to give your check boxes all the same name,
lets say chkData, and when you go

Request("chkData")

the returned values will be the VALUEs of the checked
boxes all comma delimited;

"red,blue,green"

etc

You can make an array from this and parse the items like

aData = Split(Request("chkData"), ",")
for i = lbound(aData) to ubound(aData)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top