JS语句:
- JScript code
function inquireInformation(option) { var value=option.value; alert(value); if(value=="student") { window.location.href="teacher_selectStudents.jsp"; } else if(value="teacher") { window.location.href="teacher_selectTeachers.jsp"; } else if(value="sc") { window.location.href="teacher_selectGrade.jsp"; } else if(value="allKeBiao") { window.location.href="teacher_selectAllKeBiao.jsp"; } else if(value="singleKeBiao") { window.location.href="teacher_selectSingleKeBiao.jsp"; } else{alert("hahah");} }
HTML语句:
- HTML code
<select id="infomation" onChange="inquireInformation(this)"> <option>查询信息</option> <option value="student">查询全部学生信息</option> <option value="teacher">查询全部教师信息</option> <option value="sc">查询全部学生成绩</option> <option value="allKeBiao">查询全部课表</option> <option value="singleKeBiao">查询个人课表</option> </select>
选择第三个及以下option(查询全部学生成绩以下),都一直跳到第二个界面上(查询全部教师信息界面),而不会跳到规定的页面。
也就是说只有前两个option跳转正常,下面的option的就直接跳到第二个option所跳转的界面
------解决方案--------------------------------------------------------
楼主你没有发现你小了一个“=”?
value=="student",这个正确
value="teacher",这个就不正确了,它是个赋值语句,不是个判断语句。
但是if (value="teacher")永远是“真”,因为value不为空,所以除了第一个判断,其它全部都执行
window.location.href="teacher_selectTeachers.jsp";
------解决方案--------------------------------------------------------
- JScript code
function inquireInformation(option) { var value=option.value; alert(value); if(value=="student") { window.location.href="teacher_selectStudents.jsp"; } else if(value[color=#FF0000]=[/color]"teacher") { window.location.href="teacher_selectTeachers.jsp"; } else if(value[color=#FF0000]=[/color]"sc") { window.location.href="teacher_selectGrade.jsp"; } else if(value[color=#FF0000]=[/color]"allKeBiao") { window.location.href="teacher_selectAllKeBiao.jsp"; } else if(value[color=#FF0000]=[/color]"singleKeBiao") { window.location.href="teacher_selectSingleKeBiao.jsp"; } else{alert("hahah");} }
------解决方案--------------------------------------------------------
else if(value="teacher")
------解决方案--------------------------------------------------------
function inquireInformation(option)
{
var value=option.value;
alert(value);
if(value=="student")
{
window.location.href="teacher_selectStudents.jsp";
}
else if(value=="teacher")
{
window.location.href="teacher_selectTeachers.jsp";
}
else if(value="sc")
{
window.location.href="teacher_selectGrade.jsp";
}
else if(value=="allKeBiao")