如何將js獲取的變數付給jsp中表單的action
function a(){
var lujing = document.getElementById("bigSort");
var text = lujing.options[lujing.selectedIndex].text;//獲取文字
if(text == "Java基礎學習"){
form.action = "SelectNewsServlet?type=4¤tpage=1";
}
else if(text == "Java基礎鞏固"){
form.action = "SelectNewsServlet2?type=4¤tpage=1";
}
else if(text == "Java學習視訊"){
form.action = "SelectNewsServlet3?type=4¤tpage=1";
}
else if(text == "Java討論區"){
form.action = "bNews/NewsServlet4?type=4&find=1¤tpage=1&sortid=12";
}
form.submit();
}
</script>
<form name="form" method="post" target="_parent" action="#">
<table width="216" height="98" border="0" cellpadding="0" cellspacing="0" background="fImage/leftOne.jpg">
<tr>
<td height="37"> </td>
</tr>
<tr align="center">
<td height="84">
<br> <br>
<select name="bigSort" id="bigSort">
<option></option>
<option value="9" style="background:#00FFFF">Java基礎學習</option>
<option value="10" style="background:#00FFFF">Java基礎鞏固</option>
<option value="11" style="background:#00FFFF">Java學習視訊</option>
<option value="12" style="background:#00FFFF">Java討論區</option>
<option value="13" style="background:#00FFFF">Java...</option>
<option value="14" style="background:#00FFFF">Java...</option>
</select>
<input type="submit" name="Submit" value="搜尋" onclick="a();">
</td>
</tr>
</table>
</form>