如何让"注册"按钮重定向到另一个页面?通过块或内联向按钮添加 href <script> 失败



我希望"注册"按钮在单击时重定向到另一个页面。我尝试通过块和内联为该代码添加href,但都不起作用。为什么?

<head>
<script>
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_button").disabled = false;
document.getElementById("submit_button").style.opacity = 1;
} else{
//Otherwise, disable the submit button.
document.getElementById("submit_button").disabled = true;
document.getElementById("submit_button").style.opacity = 0.3;
}
}
</script>
</head>
<form method="post">
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike" onclick="terms_changed(this)">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" id="vehicle2" name="vehicle2" value="Car" onclick="terms_changed(this)">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" id="vehicle3" name="vehicle3" value="Boat" onclick="terms_changed(this)">
<label for="vehicle3"> I have a boat</label><br>
<div>
<button type="submit" id="submit_button" style="background-color:#32CD32;color:white" disabled="">Sign Up</button>
</div>
</form>

该按钮是表单的操作提交。您必须在表单打开标记中添加一个操作,例如:action="/test/"

然后,表单将与您的表单数据一起重定向(即提交(到/test/。使用所需的目的地更改/test/

希望这能有所帮助!

最新更新