所以我有一个选项元素,我正在尝试根据单选按钮更改值。我无法以简单的方式清除/添加选项元素,所以我只想更改内部 html。它适用于Firefox,但不是在 IE 中。
我的选择
<select name="TOR" id="TOR">
<option value="MVR Only">MVR Only</option>
<option value="Employee">Employee</option>
<option value="Employee + MVR">Employee + MVR</option>
<option value="Faculty">Faculty</option>
<option value="Faculty + MVR">Faculty + MVR</option>
<option value="Students">Students</option>
<option value="Students + MVR">Students + MVR</option>
<option value="Volunteers">Volunteers</option>
<option value="Volunteers + MVR">Volunteers + MVR</option>
<option value="International Employee">International Employee</option>
<option value="International Employee + MVR">International Employee + MVR</option>
<option value="International Faculty">International Faculty</option>
<option value="International Faculty + MVR">International Faculty + MVR)</option>
<option value="International Students">International Students)</option>
<option value="International Students + MVR">International Students + MVR)</option>
<option value="International Volunteers">International Volunteers)</option>
<option value="International Volunteers + MVR">International Volunteers + MVR)</option>
</select>
JavaScript 更改选项
<script>
function RadioChange(){
var x = document.getElementById("TOR");
x.innerHTML = " ";
if(document.getElementsByName("FTE")[0].checked == true){
x.innerHTML +='<option value="MVR Only(FTE)">MVR Only(FTE)</option>';
x.innerHTML +='<option value="Employee(FTE)">Employee(FTE)</option>';
x.innerHTML +='<option value="Employee + MVR(FTE)">Employee + MVR(FTE)</option>';
x.innerHTML +='<option value="Faculty(FTE)">Faculty(FTE)</option>';
x.innerHTML +='<option value="Faculty + MVR(FTE)">Faculty + MVR(FTE)</option>';
x.innerHTML +='<option value="International Employee(FTE)">International Employee(FTE)</option>';
x.innerHTML +='<option value="International Employee + MVR(FTE)">International Employee + MVR(FTE)</option>';
x.innerHTML +='<option value="International Faculty(FTE)">International Faculty(FTE)</option>';
x.innerHTML +='<option value="International Faculty + MVR(FTE)">International Faculty + MVR(FTE)</option>';
}
if(document.getElementsByName("FTE")[1].checked==true){
x.innerHTML +='<option value="MVR Only">MVR Only</option>';
x.innerHTML +='<option value="Employee">Employee</option>';
x.innerHTML +='<option value="Employee + MVR">Employee + MVR</option>';
x.innerHTML +='<option value="Faculty">Faculty</option>';
x.innerHTML +='<option value="Faculty + MVR">Faculty + MVR</option>';
x.innerHTML +='<option value="Students">Students</option>';
x.innerHTML +='<option value="Students + MVR">Students + MVR</option>';
x.innerHTML +='<option value="Volunteers">Volunteers</option>';
x.innerHTML +='<option value="Volunteers + MVR">Volunteers + MVR</option>';
x.innerHTML +='<option value="International Employee">International Employee</option>';
x.innerHTML +='<option value="International Employee + MVR">International Employee + MVR</option>';
x.innerHTML +='<option value="International Faculty">International Faculty</option>';
x.innerHTML +='<option value="International Faculty + MVR">International Faculty + MVR)</option>';
x.innerHTML +='<option value="International Students">International Students)</option>';
x.innerHTML +='<option value="International Students + MVR">International Students + MVR)</option>';
x.innerHTML +='<option value="International Volunteers">International Volunteers)</option>';
x.innerHTML +='<option value="International Volunteers + MVR">International Volunteers + MVR)</option>';
}
}
</script>