hi, i am new to javascript and php.
i have a form with only checkboxes and a submit button.
i need to validate this form in a such a way:
ONLY IF ATLEAST ONE CHECKBOX IS CHECKED then the elements of the form are POSTED to the action specified under the action attribute of <form>
i need to get the value specified with the checked checkboxes in the page getcheckedvalues.php
i then want to run a query for each value received by the page getcheckedvalues.php
.....here is a code i cooked up with help from smethng i found online, but it doesnt work properly yet..........
<head>
<script>
function check(){
count = 0;
for(x=0; x<document.form1.checkbox.length; x++){
if(document.form1.checkbox[x].checked==true){
count++
}
}
if(count==0){
alert("You must choose atleast 1");
return false;
}
else {
<!--condition if atleast one is checked..but from here i dont know wat to do..
}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="getcheckedvalues.php" >
<input type="checkbox" name="A" value="1"/>A
<input type="checkbox" name="B" value="2" />B
<input type="checkbox" name="C" value="3"/>C
<input type="submit" name="button" id="button" value=" VOTE! " onclick="check();"/>
</form>
</body>