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
| <script>
function init(s) {
var items = new Array('a', 'b', 'c');
while(s.hasChildNodes()) {
s.removeChild(s.childNodes[0]);
}
for(i = 0; i < items.length; i++) {
var opt = document.createElement('option');
opt.value = items[i];
opt.innerHTML = items[i];
s.appendChild(opt);
}
}
function update(s1Id, s2Id) {
var s1 = document.getElementById(s1Id);
var s2 = document.getElementById(s2Id);
init(s2);
s2.removeChild(s2.options[s1.selectedIndex]);
}
</script>
<select id="s1" onChange="update(this.id, 's2')">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
<select id="s2">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select> |
Partager