Click to See Complete Forum and Search --> : checkboxes


gogotina
05-18-2003, 11:56 PM
can someone point me int the right direction so that I can return the values of the check boxes in groups? The 1st group is 1 to 10 the 2nd group is 11-20 the the 3rd is 21-30... they can select five of the ten in each group, post the sellections, then add the sellections together.
exp. (0103050709) (1112131415).....the total would be (0103050709,1112131415)
<script language="javascript">
function Fun1(form)
{
var chkd = 0;
var max = 5;
var i;
var Coma=',';
form.sellection1.value = '';
form.sellection2.value = '';
form.total.value = '';
for(i=0;i<form.length;i++)
{
if(form.elements[i].type == 'checkbox' && form.elements[i].checked)
{
if(chkd < max && i<10)
{
form.sellection1.value += form.elements[i].value;
chkd++;
}
if(chkd < max && i>10)
{
form.sellection2.value += form.elements[i].value;
chkd++;
}
else
{
alert('You are only allowed to pick ' + max + ' items');
form.total.value += form.sellection1.value ;
return false;
}
}
}
form.total.value += form.sellection1.value ;
form.total.value += Coma ;
form.total.value += form.sellection2.value ;
return true;
}
</script>
<form name="game"><input type="text" name="sellection1" value="abcde"><input type="text" name="sellection2" value="fghi"><input type="text" name="total" value="zxy"><input type="checkbox" value="01" onclick="return Fun1(this.form)">
1&nbsp;<input type="checkbox" value="02" onclick="return Fun1(this.form)">
2&nbsp; <input type="checkbox" value="03" onclick="return Fun1(this.form)">
3&nbsp;<input type="checkbox" value="04" onclick="return Fun1(this.form)">
4&nbsp; <input type="checkbox" value="05" onclick="return Fun1(this.form)">
5&nbsp;<input type="checkbox" value="06" onclick="return Fun1(this.form)">
6&nbsp; <input type="checkbox" value="07" onclick="return Fun1(this.form)">
7&nbsp;<input type="checkbox" value="08" onclick="return Fun1(this.form)">
8&nbsp; <input type="checkbox" value="09" onclick="return Fun1(this.form)">
9&nbsp;<input type="checkbox" value="10" onclick="return Fun1(this.form)">
10&nbsp; <input type="checkbox" value="11" onclick="return Fun1(this.form)">
11&nbsp;<input type="checkbox" value="12" onclick="return Fun1(this.form)">
12&nbsp; <input type="checkbox" value="13" onclick="return Fun1(this.form)">
13&nbsp;<input type="checkbox" value="14" onclick="return Fun1(this.form)">
14&nbsp; <input type="checkbox" value="15" onclick="return Fun1(this.form)">
15&nbsp;<input type="checkbox" value="16" onclick="return Fun1(this.form)">
16&nbsp; <input type="checkbox" value="17" onclick="return Fun1(this.form)">
17&nbsp;<input type="checkbox" value="18" onclick="return Fun1(this.form)">
18&nbsp; <input type="checkbox" value="19" onclick="return Fun1(this.form)">
19&nbsp;<input type="checkbox" value="20" onclick="return Fun1(this.form)">
20&nbsp; <br>
</form>