...

View Full Version : looping through forms collection



esthera
01-28-2007, 08:12 PM
I am doing as follows

For x = 1 to Request.Form.Count
response.write request.form.key(x) & "<hr>"
next

for some reason this does not pick up on checkboxes that are not checked -- why not?

Brandoe85
01-28-2007, 08:14 PM
That's because checkboxes that are not checked aren't sent to the server. Therefore they won't come up in the collection.

esthera
01-28-2007, 08:30 PM
and no way to get the names?

degsy
01-30-2007, 02:58 PM
Nope, not if they are not sent.

If you want required fields then setup a hidden form element or array to hold the fieldnames that you require.

glenngv
02-02-2007, 09:52 PM
Nope, not if they are not sent.

If you want required fields then setup a hidden form element or array to hold the fieldnames that you require.
You don't need that to validate checkboxes that are required.
If you request.form a checkbox that is not checked, its value is empty. So you can validate it if it is checked by checking if it has a value.

If Request.Form("mycheckbox")="" Then 'unchecked
Response.Write "The checkbox is unchecked!"
Else 'checked
Response.Write "The checkbox is checked!"
End If

degsy
02-06-2007, 02:59 PM
You don't need that to validate checkboxes that are required.
But that's exactly what you have done.

What you've done is hardcoded the checkbox name into your script to see if the checkbox has been submitted or not and to set a value for a variable.

Maybe I could have used compare instead of validate, but the objective is to get a value for the variable. e.g. Yes or No.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum