hi there.
i have a competition whereby users are asked to select a maximum of 5 correct things out of a choice of 12. those things need to be displayed in a database where i can see if the things that were selected are right or wrong. i have a value for the checkbox 'ckb' which i needed for the javascript to work (select 5, more than 5 will bring up an alert) but i need to display all 5 results. how to i do this?
i have gotten the javascript to work so people could only select a maximum of 5. that was based on all the check boxes having the same id. now i need to display the 5 results in the database
this is the script that only allows the user to select up to 5 checkbox values
Code:
<script type="text/javascript">
function chkcontrol(j) {
var total=0;
for(var i=0; i < document.form1.ckb.length; i++){
if(document.form1.ckb[i].checked){
total =total +1;}
if(total > 5){
alert("Please Select only five")
document.form1.ckb[j].checked = false ;
return false;
}
}
} </script>
this is the section of code that deals with the checkboxes. they have the same name but the values are different.
Code:
<table border='0' width='471' cellspacing='0' cellpadding='1' align=center>
<tr bgcolor="#ffffcc"><td width="59"> </td><td width="290" ><b>Choice</b></td></tr>
<tr bgcolor="#f1f1f1"><td align="center"><input type=checkbox name=ckb value="Sweet shop" onclick="chkcontrol(0)";></td><td >In the Sweetshop</td></tr>
<tr bgcolor="#ffffff"><td align="center"><input type=checkbox name=ckb value="Playing Chess" onclick="chkcontrol(1)";></td><td >Playing Chess </td></tr>
<tr bgcolor="#f1f1f1"><td align="center"><input type=checkbox name=ckb value="Sweet Peas Dolls" onclick="chkcontrol(2)";></td><td >With the Sweet Peas Dolls</td></tr>
<tr bgcolor="#ffffff"><td align="center"><input type=checkbox name=ckb value="Hiding between the Hamleys Bears" onclick="chkcontrol(3)" ;></td><td >Hiding between the Hamleys Bears</td></tr>
<tr bgcolor="#f1f1f1"><td align="center"><input type=checkbox name=ckb value="Racing cars on the Scalextric track" onclick="chkcontrol(4)";></td><td >Racing cars on the Scalextric track</td></tr>
<tr bgcolor="#ffffff"><td align="center"><input type=checkbox name=ckb value="Having lunch in the Regal Tea Cafe" onclick="chkcontrol(5)";></td><td >Having lunch in the Regal Tea Cafe</td></tr>
<tr bgcolor="#f1f1f1"><td align="center"><input type=checkbox name=ckb value="Trying on a Hamleys Medieval Dress Costume" onclick="chkcontrol(6)";></td><td >Trying on a Hamleys Medieval Dress Costume</td></tr>
<tr bgcolor="#ffffff"><td align="center"><input type=checkbox name=ckb value="Flying a remote controlled plane" onclick="chkcontrol(7)";></td><td >Flying a remote controlled plane </td></tr>
<tr bgcolor="#ffffff"><td align="center"><input type=checkbox name=ckb value="Playing Nerf Tag with Alice" onclick="chkcontrol(8)";></td><td> Playing Nerf Tag with Alice</td></tr>
<tr bgcolor="#ffffff"><td align="center" ><input type=checkbox name=ckb value="Playing with an Infinite Bubble Gun" onclick="chkcontrol(9)";></td><td >Playing with an Infinite Bubble Gun</td></tr>
<tr bgcolor="#ffffff"><td align="center" ><input type=checkbox name=ckb value="Peeking out behind the Lego Clone Trooper" onclick="chkcontrol(10)";></td><td >Peeking out behind the Lego Clone Trooper</td>
</tr>
</table>
now in the database i want to store all 5 results. therefore each row will have the intro info (name, address, email) but it will then have the values of the 5 checkbox values. how can i achieve this?
any helpers on this please?