Click to See Complete Forum and Search --> : How to retrieve values from a checkbox?


cusimar9
04-10-2006, 04:49 AM
It seems I've never had reason to use a checkbox until now, and they're giving me no end of hassle

How the HELL do you retrieve a value from one??

Form:


<input type="checkbox" name="optPool" id="optPool" value="" tabindex=14 style="width:20px">


VBScript:


response.write(request.form("optPool"))


Is there some strange thing I'm missing? I thought it would be the same as other inputs...

cusimar9
04-10-2006, 05:00 AM
Never mind I've figured it out now, bloody checkboxes!

omarr226
04-18-2006, 05:33 AM
how??
now i m facing dis same prb..
can u plz tell me wats da code??

cusimar9
04-18-2006, 11:05 AM
I would love to respond only I have a serious inability to read txt spk

I'll let you off this once :rolleyes:

The key is that checkboxes are in groups.


<input type="checkbox" name="pets" value="dog">
<input type="checkbox" name="pets" value="cat">
<input type="checkbox" name="pets" value="horse">


Then retrieve the values using something like this (after you've submitted the form)


if InStr(Request.Form("pets"),"dog") > 0) then response.write("Dog<BR>")
if InStr(Request.Form("pets"),"cat") > 0) then response.write("Cat<BR>")
if InStr(Request.Form("pets"),"horse") > 0) then response.write("Horse<BR>")

Ubik
04-18-2006, 12:38 PM
arrMyFormPets=split(Request.Form("pets"))

omarr226
04-18-2006, 04:46 PM
wow..dat was gr8..!!
indeed a very small,simple yet logical code..!
thanx a dozen...!