jsp页面跳转代码

来源:百度知道 编辑:UC知道 时间:2024/05/24 07:35:52
在htm文件中,设计三个单选按钮,组名为“user”,按钮名分别为“大学”、“中学”、“小学”,选中其中一个,按下"确定"分别跳转到相应的daxue.htm,zhongxue.htm,xiaoxue.htm页面。请问跳转的关键代码是什么?我本来打算在javascript中用window.location.href=“url”实现的,但是不知为什么一直不肯跳转
function checkInput(){
var user = document.getElementsByName("user");
var value1 = 0;
for(var i=0;i <user.length;i++){
if(user[i].checked)
{
value1 = user[i].value;
break;
}
}
if(value1 == 0){ window.location.href="daxue.htm";
}
if(value1=="1"){
}
if(value1=="2"){}
}
我认为只是跳转不了,因为我在
if(value1 =="0"){
alert("大学"); //这句为了测试判断条件,能够正常执行,显示 "大学"
window.location.href="daxue.htm"; //还是不能跳转
}
if(value1=="1"){
}
if(value1=="2"){
}

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>

<body>
<form action="" id="loginForm">
<input type="radio" name="user" value="0" checked>大学</input>
<input type="radio" name="user" value="1" >中学</input>
<input type="radio" name="user" value="2" >小学</input>
<input name="button" type="submit" value="登陆" onClick="checkInput();" />
</form>
</body>
<script>
function checkInput(){
var user = document.getElementsByName("user");
var form = document.getElementById("loginForm");
var value1 = 0;
for(var i=0;i <user.length;i++){