hi friends
I have using four the checkboxes in check.htm form . The selected checkbox values will be posted in the enquiry text box field of the enquiry.php file. but i didnt post the selected checkbox values in that field.
please can u give suggestion. how to solve this,
check.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function chk_unchk(val, form_name) {
dml=eval('document.'+form_name);
len=dml.elements.length;
var i=0;
for (i=0; i<len; i++) {
if (dml.elements[i].type == "checkbox") {
if (val == 1) {
dml.elements[i].checked=true;
}
else {
dml.elements[i].checked=false;
}
}
}
}
function SubmitCheckForm()
{
frmCheckform = document.Checkform;
// assigh the name of the checkbox;
var chks = document.getElementsByName('cashewnut[]');
var hasChecked = false;
// Get the checkbox array length and iterate it to see if any of them is selected
for (var i = 0; i < chks.length; i++)
{
if (chks[i].checked)
{
hasChecked = true;
break;
}
}
// if ishasChecked is false then throw the error message
if (!hasChecked)
{
alert("Please select at least one product.");
chks[0].focus();
return false;
return true;
}
// if one or more checkbox value is selected then submit the form
return confirm("Are you sure to add this product list(s)?");
//if(booSubmit == true)
// frmdryfruits.submit();
}
</script>
</head>
<body>
<form name="form1" action="enquiry.php" method="post" onSubmit="return SubmitCheckForm();">
<table>
<tr>
<td>cashewkernal</td><td><input type="checkbox" style="height: 17px;" value="kernels" name="cashewnut[]" id="cashew1"/>
</td>
<td>Flavoured cashew</td><td>
<input type="checkbox" style="height: 17px;" value="flavouured cashew" name="cashewnut[]" id="cashew2"/>
</td>
<td>Raw cashew</td><td>
<input type="checkbox" style="height: 17px;" value="rawcashew" name="cashewnut[]" id="cashew3"/>
</td>
<td>cashewnut</td><td>
<input type="checkbox" style="height: 17px;" value="cashewnut" name="cashewnut[]" id="cashew4"/>
</td>
</tr>
<tr><td><input type="submit" value="submit" name="Enquiry" value="Enquiry" ></td></tr>
</table>
</form>
</body>
</html>
Enquiry.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if(isset($_POST['cashewnut'])){
$cashew = $_POST['cashewnut'];
$n = count($cashew);
$i = 0;
echo " <p align='left'><b>Your selected products are</b>: " ."<table><tr><td>";
while ($i < $n) {
echo "<input type='checkbox' checked='checked'>{$cashew[$i]} ";
$i++;
}
echo "</td></tr></table></p>";
}
?>
<table width="200" border="0">
<tr>
<td>Name : </td><td><input type="text" name="name"><br></td>
</tr>
<tr>
<td>Comp. Name : </td><td><input type="text" name="companyname"><br></td>
</tr>
<tr>
<td>Address : </td><td><input type="text" name="address"><br></td>
</tr>
<tr>
<td>Country : </td><td><input type="text" name="country"><br></td>
</tr>
<tr>
<td>Email : </td><td><input type="text" name="email"><br></td>
</tr>
<tr>
<td>Phone : </td><td><input type="text" name="phone"><br></td>
</tr>
<tr>
<td align="left">Enquiry </td>
<td align="left"><input type="text" name="enquiry" value="<?php echo $_POST['cashewnut'];?>" onBlur="checktextbox(this);"/> <span id="enquiryerror"></field></td>
</tr>
<tr>
<td>Details : </td> <td><input type="text" name="details"><br></td>
</tr>
<tr>
<td><INPUT class="button" type="submit" name="submit" value="Submit"></td>
<td> </td>
</tr>
</table>
</body>
</html>