JavaScript qui marche sous IE6 et non sur FireFox
Bonjour, débutant dans le JavaScript j'ai écrit ce script qui permet d'avoir un champ de texte activé si le checkbox est selected sinn il sera désactivé.
Ce script marche parfaitement sous IE6, en revanche inactif sous Firefox :?
Voila mon JavaScript:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| <script type="text/javascript">
function disableInput(idInput, valeur)
{
var input = document.getElementById(idInput);
if (valeur) {
input.style.background = "#FFF";
input.readOnly=false;
}
else{
input.style.background = "#CCC";
input.value = "";
input.readOnly=true;
}
} |
l'option activer script est coché sur mon FF.
Et puis dans l'html:
Code:
1 2 3 4 5 6 7 8 9
|
<table>
<th>Enfant</th>
<td>
<input type="checkbox" name="enf" value="oui"
checked="checked" onclick="disableInput('nbenfant', this.checked);"/> oui
<input name="nbenfant" type="text" />
</td>
</table> |