form

来源:互联网 发布:node.js买什么书 编辑:程序博客网 时间:2024/05/16 11:17

通过button的reset属性,可以改变form.action的提交链接

 <#if "${(supplyDetail.state)}" == "1">
                       <form action="${contextPath}/supplier/update.html" method="post" id="testForm" class="form-horizontal">
                    <#else>
                       <form action="${contextPath}/supplier/refuse/${supplyDetail.id}.html" method="post" id="testForm" class="form-horizontal">
                    </#if>

<div class="form-actions"  align="center">    

                                    <#if "${(supplyDetail.state)}" == "1">
                                        <button type="submit" class="btn btn-primary" > 保存 </button>
                                        <button type="reset"   class="btn" onclick="history.go(-1)">返回</button>
                                    <#else>
                                        <button type="reset" class="btn btn-primary" onclick="testupdate()">同意 </button>
                                        <button type="submit" class="btn btn-danger" > 驳回 </button>
                                        <button type="reset" class="btn"  onclick="history.go(-1)"> 返回 </button>
                                    </#if>
                            </div>  

                            </form>


<script type="text/javascript">
    
    function test() {
        <!--//form.action = "${contextPath}/supplier/refuse/${supplyDetail.id}.html";-->
        document.getElementById("testForm").action="${contextPath}/supplier/refuse/${supplyDetail.id}.html";
        document.getElementById("testForm").submit();
        <!--form.submit();-->
    }
</script>

<script type="text/javascript">

    function testupdate() {
        <!--//form.action = "${contextPath}/supplier/refuse/${supplyDetail.id}.html";-->
        document.getElementById("testForm").action="${contextPath}/supplier/update.html";
        document.getElementById("testForm").submit();
        <!--form.submit();-->
    }
</script>         

0 0