I want to pass the checkbox values from my form to another PHP file upon clicking the next hyperlink. But I am unable to do so. I have javascript in my form which checks that only one checkbox is selected. To use this javascript, I need to name all my checkboxes the same. but I want to be still able to post the values to the php file for further processing.
Here is my code
Form code
<html>
<head>
<script type="text/javascript">
<!-- Begin
function checkBoxValidate(cb) {
for (j = 0; j < 8; j++) {
if (eval("document.myform.ckbox[" + j + "].checked") == true) {
document.myform.ckbox[j].checked = false;
if (j == cb) {
document.myform.ckbox[j].checked = true;
}
}
}
}
// End -->
</script>
</head>
<body>
<br>
<br><br>
<form name=myform>
<p>Please choose a variable to incrementally create your form
<div style "
margin-top:25px;
margin-left:50px;
margin-right:50px;
margin-bottom:25px;
">
<div style = "width:500px;height:275px;border:2px solid blue;
padding-top:25px;
padding-left:100px;
padding-right:100px;
padding-bottom:5px;
">
<table border = "1">
<tr>
<th>Choose One</th>
<th>Element Name </th>
<th>Element</th>
<tr>
<td><input type = "checkbox" name = "ckbox" value = "txt_box"
onClick="javascript:checkBoxValidate(0)"></td>
<td>Textbox</td>
<td><input type = "textbox" name = "text_box"></td>
</tr>
<tr>
<td><input type = "checkbox" name = "ckbox" value = "list_box"
onClick="javascript:checkBoxValidate(1)"></td>
<td>List Box</td>
<td><select>
<option value="ListItem1"></option>
<option value="ListItem1">ListItem1</option>
<option value="ListItem2">ListItem2</option>
<option value="ListItem3">ListItem3</option>
<option value="ListItem4">ListItem4</option>
</select></td>
</tr>
<tr>
<td><input type = "checkbox" name = "ckbox" value = "chk_box"
onClick="javascript:checkBoxValidate(2)"></td>
<td>Checkbox</td>
<td><input type = "checkbox" name = "checkbox"></td>
</tr>
<tr>
<td><input type = "checkbox" name = "ckbox" value = "radio"
onClick="javascript:checkBoxValidate(3)"></td>
<td>RadioButton</td>
<td><input type = "Radio" name = "Radio"></td>
</tr>
</form>
</table>
</div>
<a href = "AppForm1.html" >Back</a>   
<a href = "checkboxSubmit.php" >Next >></a>
php code
<?php
echo $_POST['ckbox'];
?>
</body>
</html>