javaweb的表单提交代码参考示例



<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/page.tld" prefix="page"%>
<script type="text/javascript" src="includes/selection.js"></script>
<script type="text/javascript" src="includes/jquery-1.3.2.js"></script>
<script type="text/javascript">
function save()
    {
    var code = document.getElementById("code").value;  //库房名称
    var name = document.getElementById("name").value;  //库房编码
    
         
    var a=true;
               
            //库区最大存储量数字验证
            if (isNaN(document.getElementById("largest_inventory").value)) {
      alert("最大存储量必须是数字");
      document.getElementById("largest_inventory").focus();
     
      return false;
      }
        if((insertStoreRoom.code.value!=""))
        {
            if((insertStoreRoom.name.value!=""))
            {
             if(insertStoreRoom.address.value!=""){
              if(insertStoreRoom.largest_inventory.value!=""){
               
               $.ajax({//验证库房编码或库房名称重复
       url:"checkStoreRoomCodeAndName.do",
       cache : false,
       type : "post",
       data : {"code":code,"name":name},
       async:false,
       dataType : "json",
       success:function(result){
         
         if(result==1){
          alert("库房编码或库房名称重复");
          a=false;
         }
        }
       });
               
               if(a){
        var form = document.insertStoreRoom; //获取此元素
                  form.action="insertStoreRoom.do";
                  form.submit();
                  }else{
                   alert("重新填写数据");
                   return false;
                  }
              }else{
               alert("最大数据量不能为空");
              }
               }else{
                alert("地址不能为空");
               }
            }
            else
            {
                alert("库房名称不能为空");
                }
            }
        else
        {
            alert("库房编码不能为空");
            }
        }


</script>
<html:javascript formName="storeRoomForm" staticJavascript="false" />
<html:form action="/insertStoreRoom" styleId="insertStoreRoom">
 <table width=90% border=0 cellpadding=4 cellspacing=0>
  <tr>
  <td class="bluetext">
    <bean:message key="travelApplication.site" />:
    &nbsp;
   </td>
    <td>
    <html:select property="site_id">
    <html:options collection="x_siteList" property="id" labelProperty="name"/>
    </html:select>
    </td>
  </tr>
  <tr>
   <td class="bluetext">库房编码:</td>
   <td><html:text property="code" /><span class="required">*</span></td>
  </tr>
  <tr>
   <td class="bluetext">库房名称:</td>
   <td><html:text property="name" /><span class="required">*</span></td>
  </tr>
  <tr>
   <td class="bluetext">地址:</td>
   <td><html:text property="address" styleId="address" /><span class="required">*</span></td>
  </tr>
  <tr>
   <td width="15%" class="bluetext">时间:</td>
   <td>
    <html:text property="date" readonly="true" size="15" />
    <a οnclick="event.cancelBubble=true;" href="javascript:showCalendar('dimg2',false,'date',null,null,'storeRoomForm')">
    <img align="absmiddle" border="0" id="dimg2" src="images/datebtn.gif" /> </a>
   </td>
  </tr>
  <tr>
   <td class="bluetext">类型:</td>
   <td><html:select property="type" >
   
      <c:if test="${sessionScope.LOGIN_USER.locale=='en'}"><html:options collection = "x_STOREROOMTYPELIST" property = "enumCode" labelProperty = "engShortDescription"/>
     
     
      </c:if>
              <c:if test="${sessionScope.LOGIN_USER.locale!='en'}"><html:options collection = "x_STOREROOMTYPELIST" property = "enumCode" labelProperty = "chnShortDescription"/>
               
              </c:if>
   </html:select>
   <span class="required">*</span></td>
  </tr>
  
  <%--<tr>
   <td class="bluetext">安全库存:</td>
   <td><html:text property="largest_inventory" /><span class="required">*</span></td>
  </tr>
  --%>
  <tr>
   <td class="bluetext">最大储存量</td>
   <td><html:text property="largest_inventory"/><span class="required">*</span></td>
  </tr>
  <tr>
   <td class="bluetext">状态:</td>
   <td><html:select property="status">
    <c:if test="${sessionScope.LOGIN_USER.locale=='zh'}">
     <html:options collection="X_ENABLEDDISABLEDLIST"
      property="enumCode" labelProperty="chnShortDescription" />
    </c:if>
    <c:if test="${sessionScope.LOGIN_USER.locale!='zh'}">
     <html:options collection="X_ENABLEDDISABLEDLIST"
      property="enumCode" labelProperty="engShortDescription" />
    </c:if>
   </html:select></td>
  </tr>
  <tr>
   <td class="bluetext">备注:</td>
   <td><html:textarea property="remark" cols="20" rows="3" /></td>
  </tr>
 </table>
 <hr />
 <div align="center">
   <%--<html:submit><bean:message key="all.save" /></html:submit>
   --%><input type="button" value="保存" οnclick="save()"/>
   &nbsp;&nbsp;&nbsp;&nbsp;
   <input type="button" value="关闭" οnclick="window.close();"/>
 </div>
</html:form>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值