Link to home
Start Free TrialLog in
Avatar of tedmcmaster
tedmcmaster

asked on

Passing variables between forms and interpreting values received in checkboxs

If you select more than one checkbox in a form and then submit the results to another page, how are the individual results identified?? For example if I submit color selections:

Color = red
Color = white
Color = blue, and I only select red and blue and submit them. What is the mechanism that allows me to identify the colors I recieve on the new page. Is it an array?

I have several text on HTML and cannot see an answer or technique using this.

Thanks


ASKER CERTIFIED SOLUTION
Avatar of snoyes_jw
snoyes_jw
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of raj3060
raj3060
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Neil_Simpson
Neil_Simpson

If you have used checkboxes then each should have a different name. The value passed to the next page will be something like ?red=true&white=&blue=true if form elements with the names red and blue and checked.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

I am not sure but try to us ID tag and identify your control or submitted value by seeing this ID value.

Eg:

<INPUT type="checkbox" id="checkBox1" name="checkBox1" value="1">RED</TD>
<INPUT type="checkbox" id="checkBox2" name="checkBox1" value="1">GREEN</TD>
<INPUT type="checkbox" id="checkBox3" name="checkBox1" value="1">BLUE</TD>

Now even if the name is same your ID value will be different. On the posted form you can fetch ID by using.
Request.getParameterById(checkBox1")

Cheers and all the best!