easyUI添加下拉列表 +++ form表单点一次,向后台提交两次

<%@ page language="java" contentType="text/html; charset=UTF-8"
 pageEncoding="UTF-8"%>

<%@ include file="/WEB-INF/views/commons/Tags.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

如果有这行,点一次提交,会运行两次submit,(即save执行一次,《$('#addORupdateTran').form》执行两次)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" type="text/css" href="${basePath }/resources/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${basePath }/resources/themes/icon.css">
<link rel="stylesheet" type="text/css" href="${basePath }/resources/css/demo.css">

<script type="text/javascript" src="${basePath }/resources/adapter/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${basePath }/resources/adapter/jquery.easyui.min.js"></script>


<!-- 国际化 -->
<script type="text/javascript" id="www" src="${basePath }/resources/adapter/common.js"></script>

<!-- easyui样式添加下拉列表 -->
<script type="text/javascript">
 $(function() {
  $('#cc').combobox({
   url : '../transport/findMaterialstype.go',
   valueField : 'codeid',
   textField : 'codename'
  });

<!-- 下拉列表添加结束 -->


  $('#addORupdateTran').form({
   url : '../transport/addOrUpdateErTransport.go',
   onSubmit : function() {
    var namee = $('#namee').val();
    var typee = $('#typee').val();
    var cc = $('#cc').combobox('getText');
    if (!namee || !typee || !cc) {
     $.messager.alert('提示', '请您输入必填项!');
     return false;
    }else {
     return true;
    }
   },
   success : function(msg) {
    top.closeDlg();
    if("false" == msg){
     alert('添加失败');
    }else{
     $.messager.alert('提示', '添加成功!');
     alert('添加成功!');
    }
   }
  });
 });
 function save(){
  $('#addORupdateTran').submit();
 }
 
</script>
</head>
<body scroll="no">
 <form id="addORupdateTran" method="post">
  
  <table>
   <tr>
    <td><span >车牌号:</span></td>
    <td><input  class="easyui-validatebox" required="true"/></td>
    <td><span >类型:</span></td>
    <td><input id="typee" class="easyui-validatebox" required="true"/></td>
   </tr>
   <tr>
    <td><span id="TransportForm.materia" class="paltform-i18n">资源:</span></td>
    <td>
    <input id="cc"  class="easyui-validatebox" required="true"/>
    
    </td>
    <td><span>载重(顿):</span></td>

   </tr>
     </table>
  <div align="center">
   <button onclick="save()">
     <span>b保存 </span>
   </button>
  </div>
 </form>
</body>
</html>

posted @ 2012-08-07 11:14  火光闪耀  阅读(428)  评论(0编辑  收藏  举报