View Full Version : Collect info from checkboxes

10-12-2003, 02:50 AM
I'm trying to get a client to push a button that will take them to a page with checkboxes. Then they check all the boxes they want and come back to the first page. How do I get the info saved from checkboxes so I can print it later?

hello everybody
<title> hello </title>
function water()
return x;

<--\\ Buttons
<INPUT TYPE="BUTTON" NAME="WATER" value="WATER" onClick=water()>
<input type="button" name="sewer" value="sewer" onClick=alert("sewer")>
<input type="button" name="underdrain" value="underdrain" onClick=alert("underdrain")>
<input type="button" name="forcemain" value="forcemain" onClick=alert("forcemain")>
<input type="button" name="reclaim" value="reclaim" onClick=alert("reclaim")>
<input type="button" name="lift_station" value="lift_station" onClick=alert("lift_station")>
<--\\ checkboxes
<p><input type="checkbox" name="water0" value="yes" checked> Water[0];
<p><input type="checkbox" name="water1" value="yes" checked> WATER[1];
<p><input type="checkbox" name="water2" value="yes" checked>
<p><input type="checkbox" name="water3" value="yes" checked>
<p><input type="checkbox" name="water4" value="yes" checked>
<p><input type="checkbox" name="water5" value="yes" checked>
<p><input type="checkbox" name="water6" value="yes" checked>
<input type="checkbox" name="water7" value="yes" checked>
<input type="checkbox" name="water8" value="yes" checked>
<input type="checkbox" name="water9" value="yes" checked>
<input type="checkbox" name="water10" value="yes" checked>


Vincent Puglia
10-12-2003, 03:30 PM

since your code is somewhat confusing -- no form tags, no code to show when or how you are returning to the initial page, no idea if this page is a child of the main page or simply a new location, etc, etc.:

to access the checkboxes, you need to call a function while passing the form object to it

<input type='button' onclick=doit(this.form)>

function doit(formObj)
var chksChecked = "";
for (var i = 0; i < formObj.length; i++)
if (formObj.elements[i].type == 'checkbox' && formObj.elements[i].checked)
chksChecked += formObj.elements[i].name + "|";

how you send it back to the other page depends on how you are returning and how you opened the checkbox page.


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum