日期:2014-05-16  浏览次数:20408 次

关于一个提交按钮转向多个页面面的问题
一个提交按钮,想根据三个radio的值来进行判断转向哪个页面,怎么搞?

比如radio的value值有1,2,3   如果radio为1,转向1.jsp,2的话转向2.jsp  


------解决方案--------------------
<script>
function c()
{
f = document.frm;
for(c=0;c <f.r.length;c++)
{
if(f.r[c].checked)
{
f.action = f.r[c].value+ ".jsp ";
break;
}
}
}
</script>
<form name= "frm " onsubmit= "c() ">
<input type= "radio " name= "r " value= "1 ">
<input type= "radio " name= "r " value= "2 ">
<input type= "radio " name= "r " value= "3 ">
<input type= "submit ">
</form>
------解决方案--------------------
改楼上的,直观一点~~

<script>
function submitTo()
{
var f = document.frm;
for(var i=0;i <f.r.length;i++)
{
if(f.r[i].checked)
{
f.action = f.r[i].getAttribute( "submitTo ");
break;
}
}
}
</script>
<form name= "frm " onsubmit= "submitTo() ">
<input type= "radio " name= "r " submitTo= "1.jsp " />
<input type= "radio " name= "r " submitTo= "2.jsp " />
<input type= "radio " name= "r " submitTo= "3.jsp " />
<input type= "submit " />
</form>