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
| <html>
<head>
<script>
function traiter(oSelect) {
var i, j ;
var label = oSelect.options[oSelect.selectedIndex].text ;
for ( i = 0 ; i < oSelect.form.elements["fruits[]"].length ; i++ ) {
if ( oSelect != oSelect.form.elements["fruits[]"][i] ) {
for ( j = 0 ; j < oSelect.form.elements["fruits[]"][i].options.length ; j++ ) {
if ( oSelect.form.elements["fruits[]"][i].options[j].text == label ) {
oSelect.form.elements["fruits[]"][i].options[j] = null ;
// Attention, y'a peut-être un effet de bord par ici
}
}
}
}
}
</script>
</head>
<body>
<form>
<select name="fruits[]" size="5" onclick="traiter(this)">
<option>Pomme
<option>Fraise
<option>Banane
<option>Mangue
</select>
<select name="fruits[]" size="5" onclick="traiter(this)">
<option>Pomme
<option>Fraise
<option>Banane
<option>Mangue
</select>
<select name="fruits[]" size="5" onclick="traiter(this)">
<option>Pomme
<option>Fraise
<option>Banane
<option>Mangue
</select>
</form>
</body>
</html> |
Partager