Attention :
tonSelect.options[tonSelect.selectedIndex].value;
Renvoie une chaîne, or
Tu testes sur un number...
Il vaut mieux faire :
Sinon, tu peux aussi mettre dans le value de tes selects le texte à afficher :
1 2 3 4 5
| <select name="valeurs" id="tonSelect" onchange="verifSelect(this);">
<option value="libellé">222</option>
<option value="libellé 999">999</option>
</select>
<input type="text" value="libellé" id="tonInput" /> |
Puis :
1 2 3 4
| function verifSelect(tonSelect){
document.getElementById('tonInput').value = document.getElementById('tonSelect').options[tonSelect.selectedIndex].value;
}
} |
Partager