求可以控制表单提交不同页面的javascript
想做一段javascript,来控制登录不同种类会员的.
也就是控制 <form 里的 action 值,该怎么控制呢?
看到之前有人写的
<script language= "javascript ">
funtion sentto(){
if(document.all.radio1.value==1){
document.all.form1.action= "ssss.asp "
}
else
document.all.form1.action= "ttt.asp ";
document.all.form1.submit;
</script>
但这个该如何应用?
最好给我写个完整的事例,谢谢了
------解决方案-------------------- <script type= "text/javascript ">
function moda(){
var myf=document.forms[ "myf "];
var radios=myf.userstyle;
var us=0;
for(var i=0;i <radios.length;i++){
if(radios[i].checked){
us=radios[i].value;
break;
}
}
switch(Number(us)){
case 1:
myf.action= "1.asp ";
break;
case 2:
myf.action= "2.asp ";
break;
default:
myf.action= "0.asp ";
}
alert( "action= "+myf.action);//测试,用的时候删除这一行
}
</script>
<form name= "myf " action= "0.asp ">
<input type= "radio " name= "userstyle " value= "0 " onclick= "moda() ">
<input type= "radio " name= "userstyle " value= "1 " onclick= "moda() ">
<input type= "radio " name= "userstyle " value= "2 " onclick= "moda() ">
<input type= "submit " value= "提交 " />
</form>