HTMLjs获取form中的action_HTMLjs获取form中的action

HTMLjs获取form中的action_HTMLjs获取form中的action用JS动态改变表单form里的action值属性的方法方法1:<form id=”form1″ name=”form1″ method=”post” action=”https://www.cnblogs.com/ly312/archive/2010/09/news/index.asp”

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

  <form id=”form1″ name=”form1″ method=”post” action=”https://www.cnblogs.com/ly312/archive/2010/09/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” onchange=”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=”https://www.cnblogs.com/ly312/archive/2010/09/news/index.asp”}

    else if (type==”case”){document.getElementById(“form1″).action=”https://www.cnblogs.com/ly312/archive/2010/09/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>  

2024最新激活全家桶教程,稳定运行到2099年,请移步至置顶文章:https://sigusoft.com/99576.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。 文章由激活谷谷主-小谷整理,转载请注明出处:https://sigusoft.com/93141.html

(0)
上一篇 2024年 5月 28日 23:42
下一篇 2024年 5月 29日 07:06

相关推荐

关注微信