zoukankan      html  css  js  c++  java
  • JavaScript动态修改html组件form的action属性

    用javaScript动态修改html组件form的action属性,可以在提交时再决定处理表单的页面。

    <%--JavaScript部分--%>
    <script language="javascript">
        <%--略掉其余代码--%>
        if(usertypevalue=="company"){
             document.form.action="./company.jsp"
             document.form.submit();
        }
         else if(usertypevalue=="user"){
            document.form.action="./user.jsp"
             document.form.submit();
         }
         else if(usertypevalue=="tourism"){
             document.form.action="./tourism.jsp"
             document.form.submit();
         }
        <%--略掉其余代码--%>
    </script>

    <%--html部分代码--%>
    <form name="form" id="form" action="" method="post">    
         <%--略掉其余代码--%>    
         <input type="radio" name="usertype" id="usertype" value="tourism">旅游局
        <input type="radio" name="usertype" id="usertype" value="company">公司
        <input type="radio" name="usertype" id="usertype" value="user" checked="checked">游客        
        <br>
        <input type="button" value="确认" onclick="validate();">
        <input type="reset" value="重置">
            <%--略掉其余代码--%>
    </form>

    这样就可以在检查用户信息后,把参数用post方法传给另一不确定jsp页面

  • 相关阅读:
    MVC 中创建自己的异常处理
    ajax 跨域解决方法
    值传递,引用传递
    值类型,引用类型 结合 栈,堆的理解
    SQL中 ALL 和 ANY 区别的
    SQL中的逻辑运算符
    使用函数输出两个数的最大值
    九句话,送给正在奋斗的我们,每天读一遍
    C语言函数调用简简介
    优秀项目经理的七个习惯
  • 原文地址:https://www.cnblogs.com/winstonet/p/6916278.html
Copyright © 2011-2022 走看看