- 1、本文档共2页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
下面小编就为大家带来一篇用JS动态改变表单form里的action值属性的两种方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。
方法1:
lt;formid=form1name=form1method=postaction=../news/index.aspgt;
nbsp; nbsp;lt;table width=100% height=43 border=0 cellpadding=0cellspacing=0gt;
nbsp;nbsp;lt;trgt;
nbsp; nbsp; nbsp;lt;td height=28gt;lt;input name=keyword type=textstyle=width:150pxid=keyword/gt;lt;/tdgt;
nbsp;nbsp;lt;/trgt;nbsp;nbsp;lt;trgt;
nbsp; nbsp; nbsp;lt;td height=28gt;lt;select name=Searchtypestyle=width:110pxid=Searchtypeonchange=Searchtype1();gt;
nbsp; nbsp; nbsp; lt;option value=news selected=selectedgt;新闻中心
lt;/optiongt;
nbsp;nbsp;nbsp;lt;optionvalue=casegt;工程案例lt;/optiongt;nbsp;nbsp;nbsp;lt;/selectgt;
nbsp; nbsp; nbsp;lt;input type=submit name=Submit value=搜索
/gt;lt;/tdgt;
nbsp;nbsp;lt;/trgt;nbsp;nbsp;lt;/tablegt;nbsp;lt;/formgt;
nbsp;lt;scriptlanguage=javascriptgt;nbsp;functionSearchtype1(){
nbsp;vartype=document.getElementById(Searchtype).options[document.getElementById(Searchtype).selectedIndex].value;
nbsp;if(type==news){document.getElementById(form1).action=../news/index.asp}
nbsp;else if
(type==case){document.getElementById(form1).action=../case/index.asp}nbsp;}
lt;/scriptgt;方法2:lt;htmlgt;lt;headgt;
lt;scriptlanguage=javascriptgt;functioncheck(){if(document.form1.a[0].checked==true)document.form1.action=1.htm
elsedocument.form1.action=2.htm
}
lt;/scriptgt;lt;/headgt;lt;bodygt;
lt;formname=form1method=postaction=onSubmit=check();gt;
转到页面一lt;inputtype=radioname=agt;转到页面二lt;inputtype=radioname=agt;lt;inputname=type=submitvalue=提交gt;lt;/formgt;
lt;/bodygt;lt;/htmlgt;nbsp;
以上这篇用JS动态改变表单form里的action值属性的两种方法就是小编分享给大家的
全部内容了,希望能给大家一个参考
文档评论(0)