✔ 最佳答案
(1)
The javascript section
var options0 = new Array('A', 'B', 'C');
var options1 = new Array('D', 'E', 'F');
function changeOptions(index)
{
// remove option list in select
var select1 = document.getElementById("Select1");
var size = select1.length;
for (var i = size-1; i >= 0; i--)
select1.remove(i);
// populate option list
if (index == 0) {
size = options0.length;
for (var i = 0; i < size; i++)
addItem(select1, options0[i]);
}
else if (index == 1) {
size = options1.length
for (var i = 0; i < size; i++)
addItem(select1, options1[i]);
}
}
function addItem(select1, val)
{
var oOption = new Option(val, val);
select1.options.add(oOption);
}
function checkField()
{
var field1 = document.getElementById("Field1");
if (!field1.value.length) {
alert('Field1 is blank.');
return false;
}
else
return true;
}
The html section
<input type="select" id="Select2" name="Select2" onchange="changeOptions(this.selectedIndex)" ]
<option ]One
<options ]Two
<input type="select" id="Select1" name="Select1" ]
(2)
<input type="radio" name="Radio1" onclick="this.form.Field1.disabled = true" ]
<input type="radio" name="Radio1" onclick="this.form.Field1.disabled = false" ]
<input type="text" id="Field1" name="Field1" ]
(3)
<input type="submit" onclick="return checkField()" ]
Replace ] closing tag >