如果变量money等于100,我试图让我的javascript代码重定向到Index.html页面。这是html表单代码:
<form id = "form" action = "">
<h1> Enter the amount of money you would like to spend on your next trip. </h1><br>
<div class="input-group">
<span class="input-group-addon">$</span>
<input type="text" name="money" class="form-control">
</div>
<br>
<button type="submit" class="btn btn-default" onclick = "MoneyForTrip()">Show Trips</button>
</form>
和javascript:
var money;
function MoneyForTrip()
{
money = parseInt(
document.getElementById('form').money.value);
if (money == 100)
{
window.location="Index.html";
}
else
{
window.alert("Enter another number");
}
}
如果钱等于 100,我知道如何让它重定向到 Index.html 吗?