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

求一段代码,简单的选择操作!50分相送,描述清晰
<form>
<ul>
    <li> <input   name= "search "   type= "text "   class= "search "/> </li>
    <li> <input   name= "radio "   type= "radio "   value= " "   class= "radio "   /> 搜索引擎   <input   name= "radio "   type= "radio "   value= " "   class= "radio "/> 数据库 </li>
    <li> <input   name= " "   type= "submit "   class= "submit "   /> </li>
</ul>
</form>
------------------------------------
根据两个radio的不同选择,调用不同的函数,然后提交后执行
比如,选中“搜索引擎”,点击提交后,就将数据提交到baidu.com。     选择数据库后,就链接到test.asp,将参数传递过去

求一段详细代码,谢谢

------解决方案--------------------
<form onsubmit= "if(document.getElementById( 'radio1 ')[0].checked){form1.acrion= 'http://www.baidu.com '}else{form1.action= 'test.asp '};return true " name= "form1 ">
<ul>
<li> <input name= "search " type= "text " class= "search "/> </li>
<li> <input name= "radio1 " type= "radio " value= " " class= "radio " /> 搜索引擎 <input name= "radio1 " type= "radio " value= " " class= "radio "/> 数据库 </li>
<li> <input name= " " type= "submit " class= "submit " /> </li>
</ul>
</form>

------解决方案--------------------
<form>
<ul>
<li> <input name= "search " type= "text " class= "search "/> </li>
<li> <input name= "radio " type= "radio " value= " " class= "radio " onclick= "if(checked)this.form.action= 'http://www.baidu.com ' " /> 搜索引擎 <input name= "radio " type= "radio " value= " " class= "radio " onclick= "if(checked)this.form.action= 'test.asp ' " /> 数据库 </li>
<li> <input name= " " type= "submit " class= "submit " /> </li>
</ul>
</form>
------解决方案--------------------

<form onsubmit= "if(document.getElementById( 'radio1 ')[0].checked){form1.acrion= 'http://www.baidu.com '}else{form1.action= 'test.asp '};return true " name= "form1 ">
<ul>
<li> <input name= "search " type= "text " class= "search "/> </li>
<li> <input name= "radio1 " type= "radio " value= " " class= "radio " /> 搜索引擎 <input name= "radio1 " type= "radio " value= " " class= "radio "/> 数据库 </li>
<li> <input name= " " type= "submit " class= "submit " /> </li>
</ul>
</form>

hbhbhbhbhb1021(天外水火(我要多努力))

用错了getElementById( 'radio1 ')[0]
你这样肯定报错
应该是 getElementsByName( 'radio1 ')[0]
------解决方案--------------------
2楼的倒是没错 反正实现的方法很多
另外不知道这么写是不是好点
<form onsubmit= "if(document.getElementsByName( 'radio1 ')[0].checked){this.acrion= 'http://www.baidu