tfp.
hvis du skal anvende mere en 2 select boxe, kunne du overveje at lave det som et array.
demo:
http://olsensweb.dk/test/experten/spm/938102/ver3.htm <!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css">
</style>
<script type="text/javascript">
/*
// standart
function EnableSelect(no){
//var lng = document.form1["select[]"].length; // OK
var lng = document.form1["button[]"].length; // OK
for(i=0; i<lng; i++){
if(i==no){
document.form1["button[]"][i].disabled=true;
document.form1["select[]"][i].disabled=false;
}
else{
document.form1["button[]"][i].disabled=false;
document.form1["select[]"][i].disabled=true;
}
}
}
*/
// som DOM, hvilke som regl lidt hurtigere
function EnableSelect(no){
var SelectNodeList = document.getElementsByName("select[]");
var ButtonNodeList = document.getElementsByName("button[]");
var lng = SelectNodeList.length;
for(i=0; i<lng; i++){
if(i==no){
ButtonNodeList[i].disabled=true;
SelectNodeList[i].disabled=false;
}
else{
ButtonNodeList[i].disabled=false;
SelectNodeList[i].disabled=true;
}
}
}
</script>
</head>
<body>
<p> </p>
<form name="form1" method="post" action="test.php">
<p>
<select name="select[]" disabled="disabled">
<option value="01">tekst line 01</option>
<option value="02">tekst line 02</option>
<option value="03">tekst line 03</option>
<option value="04">tekst line 04</option>
<option value="05">tekst line 05</option>
</select>
<input type="button" name="button[]" value="Enable select box 0" onclick="EnableSelect(0)">
</p>
<p>
<select name="select[]" disabled="disabled">
<option value="11">tekst line 11</option>
<option value="12">tekst line 12</option>
<option value="13">tekst line 13</option>
<option value="14">tekst line 14</option>
<option value="15">tekst line 15</option>
</select>
<input type="button" name="button[]" value="Enable select box 1" onclick="EnableSelect(1)">
</p>
<p>
<select name="select[]" disabled="disabled">
<option value="21">tekst line 21</option>
<option value="22">tekst line 22</option>
<option value="23">tekst line 23</option>
<option value="24">tekst line 24</option>
<option value="25">tekst line 25</option>
</select>
<input type="button" name="button[]" value="Enable select box 2" onclick="EnableSelect(2)">
</p>
<p>
<select name="select[]" disabled="disabled">
<option value="31">tekst line 31</option>
<option value="32">tekst line 32</option>
<option value="33">tekst line 33</option>
<option value="34">tekst line 34</option>
<option value="35">tekst line 35</option>
</select>
<input type="button" name="button[]" value="Enable select box 3" onclick="EnableSelect(3)">
</p>
<p>
<select name="select[]" disabled="disabled">
<option value="41">tekst line 41</option>
<option value="42">tekst line 42</option>
<option value="43">tekst line 43</option>
<option value="44">tekst line 44</option>
<option value="45">tekst line 45</option>
</select>
<input type="button" name="button[]" value="Enable select box 4" onclick="EnableSelect(4)">
</p>
<input type="submit" name="button3" id="button3" value="Submit">
</form>
<p> </p>
</body>
</html>