我是一个新手,实际上对Java语言一无所知,所以我事先表示歉意。
我有两个要禁用的按钮,直到单击复选框。似乎只有一个按钮可以使用我的代码。
function terms_changed(termsCheckBox) {
//If the checkbox has been checked
if (termsCheckBox.checked) {
//Set the disabled property to FALSE and enable the button.
document.getElementById("submit_button2").disabled = false;
} else {
//Otherwise, disable the submit button.
document.getElementById("submit_button2").disabled = true;
}
}
function terms_changed(termsCheckBox) {
//If the checkbox has been checked
if (termsCheckBox.checked) {
//Set the disabled property to FALSE and enable the button.
document.getElementById("test").disabled = false;
} else {
//Otherwise, disable the submit button.
document.getElementById("test").disabled = true;
}
}
<form method="post">
<div><label for="terms_and_conditions">I understand</label><input type="checkbox" id="terms_and_conditions" onclick="terms_changed(this)" /></div>
<div>
<button id="test" button type="button" disabled onclick="window.location.href = '/innovation/vision-test/amd/';">Start 1st test</button>
<button id="submit_button2" button type="button" disabled onclick="window.location.href = '/innovation/vision-test/acuity/';">Start the 2nd test</button>
</div>
</form>