Reset Checkbox Value Resolue
Bonjours,
Hey merci beaucoup Sebhm ca marche a merveille et merci a toi aussi SpaceFrog
je vais testé ta solution aussi merci bcp les gas.
voila le code avec la solution initégré pour ceux qui vont rencontré le méme
soucie
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| <?php
error_reporting(0);
?>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Dolomats in the house!</title>
</head><body bgcolor="#000000" text="#ffffff">
<script type="text/javascript">
function reset_checkbox() {
for(var i=1;i<=6;i++)
document.getElementById('produit'+i).checked=false;
}
</script>
<center>
<u>
</u><h1><u>Dolomats in the house!</u></h1>
<u><u>
</u></u>
<form method="post" action="index.php" id='form-commande'>
<table style="text-align: center;" border="0" width="80%">
<tbody><tr>
<td><img src="images/boot2_s.jpg" width="92" height="114"></td>
<td><img src="images/boot_s.jpg" width="96" height="113"></td>
<td><img src="images/hat_s.jpg" width="99" height="80"></td>
</tr><tr>
<td><input name="produit[]" id="produit1" type="checkbox" value="239" <?php foreach($_POST[produit] as $produit){ if($produit == "239"){ echo('checked="checked"'); break;} }?>>239$</td>
<td><input name="produit[]" id="produit2" type="checkbox" value="219" <?php foreach($_POST[produit] as $produit){ if($produit == "219"){ echo('checked="checked"'); break;} }?>>219$</td>
<td><input name="produit[]" id="produit3" type="checkbox" value="300" <?php foreach($_POST[produit] as $produit){ if($produit == "300"){ echo('checked="checked"'); break;} }?>>300$</td>
</tr><tr>
<td><img src="images/wool_s.jpg" width="96" height="113"></td>
<td><img src="images/jeans_s.jpg" width="96" height="113"></td>
<td><img src="images/samta_s.jpg" width="99" height="80"></td>
</tr><tr>
<td><input name="produit[]" id="produit4" type="checkbox" value="89" <?php foreach($_POST[produit] as $produit){ if($produit == "89"){ echo('checked="checked"'); break;} }?>>89$</td>
<td><input name="produit[]" id="produit5" type="checkbox" value="45" <?php foreach($_POST[produit] as $produit){ if($produit == "45"){ echo('checked="checked"'); break;} }?>>45$</td>
<td><input name="produit[]" id="produit6" type="checkbox" value="25" <?php foreach($_POST[produit] as $produit){ if($produit == "25"){ echo('checked="checked"'); break;} }?>>25$</td>
</tr><tr><td colspan="3"><input value="Commander" type="submit" > <input type="button" onclick="reset_checkbox();" value="reset">
</td></tr></tbody></table>
</form>
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dolomats", $con);
if(isset($_POST[produit])){
$montant_commande = 0;
foreach($_POST[produit] as $produit){
$montant_commande = $montant_commande + $produit;
mysql_query("INSERT INTO commande (montant_produit) VALUES ($produit)");
}
echo ("Le montant de la commande est de : $montant_commande");
}
mysql_close($con);
?>
</center></body></html> |
A bientôt!!! :ccool: