Calvin80
Respect is key
Hello all
voilà g ecrit une fonction javascript qui fonctionne nickel avec un vrai browser (firefox) mais qui foire avec internet explorer.
voici le script:
et voic mon formulaire
si qq'un sait me dire pkoi ça foire sous IE ....
merci![/code]
voilà g ecrit une fonction javascript qui fonctionne nickel avec un vrai browser (firefox) mais qui foire avec internet explorer.
voici le script:
Code:
function VerifNbChecked(formulaire, val)
{
var nb=0;
var diff=0;
for (var i = 0; i < formulaire.elements.length; i++)
{
if(formulaire.elements[i].checked)
nb++;
}
if(nb<val){
diff=val-nb;
alert('Error: you did not choose enough functions\n Number of still function(s) to choose : '+diff);
}
else
formulaire.submit();
}
Code:
<FORM name="functions" action="index.php?p=vchoosefunctions" method="POST" enctype="multipart/form-data">
<table width="99%">
<tr><td colspan="3" align="center" class="title"> Proposed functions</td></tr>
<tr>
<td> <input type="checkbox" name="selectedcategories[]" value="1" onchange="DisplayNbChecked(document.functions, this, document.functions.remaining, '5')">category1 </td>
<td> <input type="checkbox" name="selectedcategories[]" value="2" onchange="DisplayNbChecked(document.functions, this, document.functions.remaining, '5')">category2 </td>
<td> <input type="checkbox" name="selectedcategories[]" value="3" onchange="DisplayNbChecked(document.functions, this, document.functions.remaining, '5')">category3 </td>
</tr>
<tr>
<td> <input type="checkbox" name="selectedcategories[]" value="4" onchange="DisplayNbChecked(document.functions, this, document.functions.remaining, '5')">category4 </td>
<td> <input type="checkbox" name="selectedcategories[]" value="5" onchange="DisplayNbChecked(document.functions, this, document.functions.remaining, '5')">category5 </td>
<td> <input type="checkbox" name="selectedcategories[]" value="6" onchange="DisplayNbChecked(document.functions, this, document.functions.remaining, '5')">category6 </td>
</tr>
<tr>
<td colspan="3" align="left"><h5>Nb of functions still to choose :<input type="text" name="remaining" style="width:30px; border:0px;"></h5></td>
</tr>
<tr>
<td colspan="3" align="right"><input type="button" value="Validate Functions" onClick="VerifNbChecked(document.functions, '5')"></td>
</tr>
</table>
</FORM>
merci![/code]