PDA

View Full Version : multiple checkboxes with server side?.



vijk2001
09-30-2002, 08:48 PM
I have a form with three checkboxes and multiple items shd be selected BUT

<form>
What type of pets do you have?
cat <input type="checkbox" name="pet" value="cat">
dog <input type="checkbox" name="pet" value="dog">
rabbit <input type="checkbox" name="pet" value="rabbit" checked>
</form>
IF I SELECT MULTIPLE ITEMS AND CLICK ON SUBMIT BUTTON.
THE QUERY submit_query WILL HAVE TAKEN ONLY ONE VALUE.

E.G:
CLICKED ON DOG AND RABBIT.
QUERY TAKES INPUT AS "DOG" NOT AS "DOG RABBIT" .why????

In ACTION=SrvGetParams

I AM USING SERVLETS FOR SERVER SIDE PROCESSING AND MY STATEMENTS are

String AnimalType = request.getParameter("AnimalType")

Then construct my SQL query as:

query ="scratch..submit_query "
+" ' " +AnimalType+ " ' "........
......... other form params...!...


__________________
vijay...life is awesome!

firepages
10-01-2002, 03:34 AM
turn the pets input into an array ...


cat <input type="checkbox" name="pet[]" value="cat">
dog <input type="checkbox" name="pet[]" value="dog">
rabbit <input type="checkbox" name="pet[]" value="rabbit" checked>

now check your pets variable , it will be an array containing the values you selected.