我在学习JSP中,遇到个问题。我的代码是:
<%@ page contentType="text/html;charset=GBK" buffer="none"%>
<html>
<body>
<form method="POST">
<select name="select">
<option value="1" selected><a href="www.baidu.com" style="text-decoration:none;">1</a></option>
<option value="2"><a href="www.163.com" style="text-decoration:none;">2</a></option>
<option value="3"><a href="www.china.com" style="text-decoration:none;">3</a></option>
</select>
</form>
</body>
</html>
我要的目的是:当我点选下拉框2时,自动打开:www.163.com;点选下拉框3时,自动打开www.china.com;
急死我了,我不知道怎么做,帮我看下,怎么改代码。。
<%@ page contentType="text/html;charset=GBK" buffer="none"%>
<html>
<body>
<form method="POST">
<select name="select">
<option value="1" selected><a href="www.baidu.com" style="text-decoration:none;">1</a></option>
<option value="2"><a href="www.163.com" style="text-decoration:none;">2</a></option>
<option value="3"><a href="www.china.com" style="text-decoration:none;">3</a></option>
</select>
</form>
</body>
</html>
我要的目的是:当我点选下拉框2时,自动打开:www.163.com;点选下拉框3时,自动打开www.china.com;
急死我了,我不知道怎么做,帮我看下,怎么改代码。。
<select name="select" onchang="changWeb(this)">
<option value="1" selected> 1 </option>
<option value="2"> 2 </option>
<option value="3"> 3 </option>
</select>在head中加入JS代码
<script >
function changWeb(selectObj){
var i = selectObj.options[selectObj.selectedIndex].value
if(i == "1"){
widows.open("www.baidu.com");
}else if(i == "2"){
widows.open("www.163.com");
}else if(i == "3"){
widows.open("www.china.com");
}
}
</script>
<html>
<head>
<script>
function changWeb(selectObj){
var i = selectObj.options[selectObj.selectedIndex].value
if(i == "1"){
widows.open("www.baidu.com");
}else if(i == "2"){
widows.open("www.163.com");
}else if(i == "3"){
widows.open("www.china.com");
}
}
</script>
</head>
<body>
<form method="POST">
<select name="select" onchang="changWeb(this)">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</form>
</body>
</html>
<body>
<form method="POST">
<select name="select" onchange="openla(this)">
<option value="http://www.baidu.com" selected> 1 </option>
<option value="http://www.163.com">2 </option>
<option value="http://www.china.com"> 3 </option>
</select>
</form>
</body>
</html>
<script>
function openla(obj){
window.open(obj.value);
}
</script>
简单点,不知道LZ还满意不..