jquery clone() 初试

Code:
  1. <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>  
  2. <%  
  3. String path = request.getContextPath();  
  4. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  
  5. %>  
  6.   
  7. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
  8. <html>  
  9. <head>  
  10. <script src="/test/js/jquery.js" type="text/javascript" charset="utf-8"></script>   
  11. <script type="text/javascript">  
  12.     $(document).ready(function() {   
  13.           
  14.         var employeNum=0;  
  15.           
  16.         var url="/test/monitorMethod.do?json=json"  
  17.         $.post(url,null,function (date){  
  18.                 var objs=eval(date);  
  19.                 for(var i in objs) {  
  20.                     var obj=objs[i];  
  21.                     $("#listMethod").append("<input type=checkbox name=selMethod value="+obj.num+">"+obj.num+obj.name+"<br>");  
  22.                 }  
  23.         });  
  24.           
  25.         var url="/test/employe.do?json=json"  
  26.         $.post(url,null,function (date){  
  27.             var objs=eval(date);  
  28.               
  29.             $("#monintorEmployes,#collator,#auditor").empty();  
  30.             $("#monintorEmployes,#collator,#auditor").append("<option disabled=disabled value=0>编号    姓名</option>");  
  31.             for(var i in objs) {  
  32.                 var obj=objs[i];  
  33.                 employeNum++;  
  34.                 $("#monintorEmployes,#collator,#auditor").append("<option value="+obj.num+">"+obj.num+" "+obj.name+"</option>");  
  35.             }  
  36.         });  
  37.           
  38.         $("#sub").click(function(){  
  39.             var Num=$("#num").val();  
  40.             var num=$.trim(Num);  
  41.             var Name=$("#name").val();  
  42.             var name=$.trim(Name);  
  43.             var intervalTime=$("#intervalTime").val();  
  44.             var year=$("#year").val();  
  45.             var month=$("#month").val();  
  46.             var day=$("#day").val();  
  47.             var monitorTime=year+"-"+month+"-"+day;  
  48.             var NoiseDevice=$("#noiseDevice").val();  
  49.             var noiseDevice=$.trim(NoiseDevice);  
  50.             var WindDevice=$("#windDevice").val();  
  51.             var windDevice=$.trim(windDevice);  
  52.             var Weather=$("#weather").val();  
  53.             var weather=$.trim(Weather);  
  54.             var BeforeMonitor=$("#beforeMonitor").val();  
  55.             var beforeMonitor=$.trim(BeforeMonitor);  
  56.             var AfterMonitor=$("#afterMonitor").val();  
  57.             var afterMonitor=$.trim(AfterMonitor);  
  58.             var VerifyDevice=$("#verifyDevice").val();  
  59.             var verifyDevice=$.trim(VerifyDevice);  
  60.             var VerifyDeviceNum=$("#verifyDeviceNum").val();  
  61.             var verifyDeviceNum=$.trim(VerifyDeviceNum);  
  62.             var Content=$("#content").val();  
  63.             var content=$.trim(Content);  
  64.             var BeMonitoredSign=$("#beMonitoredSign").val();  
  65.             var beMonitoredSign=$.trim(BeMonitoredSign);  
  66.             var collator_num=$("#collator").val();  
  67.             var auditor_num=$("#auditor").val();  
  68.               
  69.             //var monintorEmployeStr=$("#monintorEmployes").val();  
  70.             //alert(monintorEmployeStr);  
  71.               
  72.             var monintorEmployeStr="";  
  73.             $("[name='monintorEmployes']").each(function(){  
  74.                 if($(this).val()!=null && monintorEmployeStr.indexOf($(this).val())==-1)  
  75.                     monintorEmployeStr+=$(this).val()+",";  
  76.             })  
  77.             monintorEmployeStr=monintorEmployeStr.substring(0,monintorEmployeStr.length-1);  
  78.             alert(monintorEmployeStr);  
  79.             var value="";  
  80.             $("[name='selMethod']").each(function(){  
  81.                 if(this.checked)  
  82.                     value+=$(this).val()+",";  
  83.             })  
  84.             var monintorMethodStr=value.substring(0,value.length-1);  
  85.               
  86.             var url="/test/monitorReport.do?command=addMonitorReport";  
  87.             $.post(url,{num:num,name:name,intervalTime:intervalTime,monitorTime:monitorTime,  
  88.                         noiseDevice:noiseDevice,windDevice:windDevice,weather:weather,beforeMonitor:beforeMonitor,  
  89.                         afterMonitor:afterMonitor,verifyDevice:verifyDevice,verifyDeviceNum:verifyDeviceNum,  
  90.                         content:content,beMonitoredSign:beMonitoredSign,collator_num:collator_num,  
  91.                         auditor_num:auditor_num,monintorEmployeStr:monintorEmployeStr,monintorMethodStr:monintorMethodStr},  
  92.                 function (date){  
  93.                     alert("添加成功");  
  94.             });  
  95.         });  
  96.           
  97.         $("#addMonintor").click(function(){  
  98.             if($(this).parent().children().size()<=employeNum)  
  99.                 $("#monintorEmployes").clone().insertBefore($(this));  
  100.             else  
  101.                 alert("超过员工数,不能在添加了");  
  102.         });  
  103.          
  104.     });   
  105. </script>  
  106. </head>   
  107.   <body>  
  108.                 <h2 align="center">福州市环境监测站</h2>  
  109.                 <h3 align="center">噪声测量记录表(首页)</h3>  
  110.     <table border="1" cellspacing="0" width="80%" align="center" style="">  
  111.         <tr>  
  112.             <td width="10%">任务编号:</td>  
  113.             <td width="40%" colspan="2"><input type="text" id="num" name="num"></td>  
  114.             <td width="10%">监测地点:</td>  
  115.             <td width="40%" colspan="2"><input type="text" id="address" name="address" size="30"></td>  
  116.         </tr>  
  117.         <tr>  
  118.             <td width="10%">监测日期:</td>  
  119.             <td width="60%" colspan="4"><input type="text" id="year" name="year" size="4">年<input type="text" id="month" name="month" size="2">月<input type="text" id="day" name="day" size="2">日</td>  
  120.             <td width="30%">昼间<input type="radio" id="intervalTime" name="intervalTime" value="1" checked="checked">  
  121.                 夜间<input type="radio" id="intervalTime" name="intervalTime" value="2">  
  122.             </td>  
  123.         </tr>  
  124.         <tr>  
  125.             <td width="10%">监测仪器及编号</td>  
  126.             <td width="30%" colspan="2"><div>噪声仪器:<input type="text" id="noiseDevice" name="noiseDevice">  
  127.                                          <br>风速仪器:<input type="text" id="windDevice" name="windDevice"></div></td>  
  128.             <td width="10%">气象条件</td>  
  129.             <td width="50%" colspan="2"><textarea rows="3" cols="30" id="weather" name="weather"></textarea></td>  
  130.         </tr>  
  131.         <tr>  
  132.             <td width="10%">校 准 值</td>  
  133.             <td width="20%">测量前:<input type="text" id="beforeMonitor" name="beforeMonitor" size="5">dB</td>  
  134.             <td width="20%">测量后:<input type="text" id="afterMonitor" name="afterMonitor" size="5">dB</td>  
  135.             <td width="10%">校准仪器</td>  
  136.             <td width="20%"><input type="text" id="verifyDevice" name="verifyDevice" size="15"></td>  
  137.             <td width="20%">编号<input type="text" id="verifyDeviceNum" name="verifyDeviceNum" size="12"></td>  
  138.         </tr>  
  139.         <tr>  
  140.             <td width="10%">监测方法</td>  
  141.             <td colspan="5" width="90%"><div id="listMethod">  
  142.                   
  143.             </div></td>  
  144.         </tr>  
  145.         <tr id="a">  
  146.             <td width="10%">监测人员:</td>  
  147.             <td colspan="5" width="90%">  
  148.             <select id="monintorEmployes" name="monintorEmployes">  
  149.             </select>  
  150.             <img src="/test/images/add.jpg" id="addMonintor">  
  151.             </td>  
  152.         </tr>  
  153.         <tr>  
  154.             <td width="5%" rowspan="2">监测工况:</td>  
  155.             <td colspan="5" width="95%"><textarea rows="20" cols="90" id="content" name="content"></textarea></td>  
  156.         </tr>  
  157.         <tr>  
  158.             <td colspan="3" width="80%"></td>  
  159.             <td colspan="2" width="20%" align="right">被监测方签字<input type="text" id="beMonitoredSign" name="beMonitoredSign"></td>  
  160.         </tr>  
  161.         <tr>  
  162.               
  163.             <td width="20%" align="center" colspan="3">  
  164.                 校对者:<select id="collator" name="collator">  
  165.                 </select>  
  166.             </td>  
  167.             <td width="20%" align="center" colspan="3">  
  168.                 审核者:<select id="auditor" name="auditor">  
  169.                 </select>  
  170.             </td>  
  171.         </tr>  
  172.         <tr>  
  173.             <td colspan="6" width="100%" align="center"><input type="button" id="sub" value="提交" size="20"></td>  
  174.         </tr>  
  175.     </table>  
  176.   </body>  
  177. </html>  

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值