首先,form肯定是不能嵌套使用的。其次,对于应该调用哪个页面来处理form,也可以交给后台来处理,由后台来根据radio类型的值来决定采用哪个方法对form里边的值来处理,这样的话比浏览器端的处理要更合理和安全些。
如果一定要如你所说的要求,可以这样处理。
只用一个form,写一个onsubmit函数对action做出动态的判断。
<FORM name=form1 action=1.php method=post onSubmit="chooseAction(this);">
......
<script type="text/javascript">
function chooseAction(form) {
if(document.getElementById("f").checked) {
form.action = "1.php";
} else {
form.action = "2.php";
}
}
</script>
如果一定要如你所说的要求,可以这样处理。
只用一个form,写一个onsubmit函数对action做出动态的判断。
<FORM name=form1 action=1.php method=post onSubmit="chooseAction(this);">
......
<script type="text/javascript">
function chooseAction(form) {
if(document.getElementById("f").checked) {
form.action = "1.php";
} else {
form.action = "2.php";
}
}
</script>
下面这段你试试.
<script language="javascript">
function check(){
var f_checked = document.getElementById("f").checked;
var e_checked = document.getElementById("e").checked;
if (f_checked == true){
document.getElementById("form1").action = "1.php";
document.getElementById("form1").submit();
}else if(e_checked == true){
document.getElementById("form1").action = "2.php";
document.getElementById("form1").submit();
}
}
</script>
<form name="form1" id="form1" method="post" onsubmit="check();">
<label for="f" title="1"><input id="f" name="test" type="radio" value="1" checked="checked" /><font size="-1" color="#000000">1 </font></label>
<label for="e" title="1"><input id="e" name="test" type="radio" value="2" /><font size="-1" color="#000000">2 </font></label>
<input type="submit" value="test" />
</form>