js动态改变form的action的值,即动态改变提交位置
form表单
<form action="${path }/schemeChild/save" method="post" id="child_form">
<table style="width:100%;border:0;cellspacing:0;cellpadding:0;" class="vtb">
<tr>
<td width="15%" class="dright">名称: </td>
<td class="dleft"><input type="text" name="name" maxlength="25" class="form-control" style="width:70%"/></td>
<td width="15%" class="dright">编码: </td>
<td class="dleft"><input type="text" name="code" maxlength="25" class="form-control" style="width:70%"/></td>
</tr>
<tr>
<td colspan="4" align="center">
<a href="javascript:void(0);" class="btn btn-default" onclick="javascript:panel_close();">返回</a>
<a href="javascript:void(0);" class="btn btn-success" onclick="javascript:childSubmit(0);">新增保存</a>
<a href="javascript:void(0);" class="btn btn-success" onclick="javascript:childSubmit(1);">修改保存</a>
</td>
</tr>
</table>
</form>`
js动态设置action的值
<script type="text/javascript">
childSubmit(flag){
if(flag == 1){//判断是新增保存还是修改保存
$('#child_form').action = path + "/schemeChild/update";
}
$('#child_form').submit();
}
</script>