用JS动态改变表单form里的action值属性的方法

方法1:

<form id="form1" name="form1" method="post" action="../news/index.asp">
      <table width="100%" height="43" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td height="28"><input name="keyword" type="text" style="width:150px" id="keyword"/></td>
        </tr>
        <tr>
          <td height="28"><select name="Searchtype"  style="width:110px" id="Searchtype" οnchange="Searchtype1();">
            <option value="news" selected="selected">新闻中心</option>
            <option value="case">工程案例</option>
          </select>
          <input type="submit" name="Submit" value="搜索" /></td>
        </tr>
      </table>
  </form>
  <script language="javascript">
  function Searchtype1(){
  var type=document.getElementById("Searchtype").options[document.getElementById("Searchtype").selectedIndex].value;
  if (type=="news"){document.getElementById("form1").action="../news/index.asp"}
  else if (type=="case"){document.getElementById("form1").action="../case/index.asp"}
  }
  </script>

 

方法2:

<html>
<head>
<script language="javascript">
function check(){
if(document.form1.a[0].checked==true)
document.form1.action="1.htm"
else
document.form1.action="2.htm"
}
</script>
</head>
<body>
<form name="form1" method="post" action="" onSubmit="check();">
转到页面一<input type="radio" name="a">
转到页面二<input type="radio" name="a">
<input name="" type="submit" value="提交">
</form>
</body>
</html>  

转载于:https://www.cnblogs.com/ly312/archive/2010/09/14/1825590.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值