web中的大量操作,web大量操作
1,大量操作之大量刪除(增刪改)
<script type="text/javascript"> function seltAll(){ var chckBoxSign = document.getElementById("ckb"); //ckb 全選/反選的選擇框id var chckBox = document.getElementsByName("chckBox"); //所有的選擇框其那麼都是chckBox var num = chckBox.length; if(chckBoxSign.checked){ for(var index =0 ; index<num ; index++){ chckBox[index].checked = true; } }else{ for(var index =0 ; index<num ; index++){ chckBox[index].checked = false; } } } function deleSeltedRecords(){ var chckBox = document.getElementsByName("chckBox"); var num = chckBox.length; var ids = ""; for(var index =0 ; index<num ; index++){ if(chckBox[index].checked){ ids += chckBox[index].value + ","; } } if(ids!=""){ if(window.confirm("確定刪除所選記錄?")){ $.ajax( { type : "post", url : '../g3/history-no!batchDelete.action?ids=' + ids, //要自行刪除的action dataType : 'json', success : function(data) { alert("刪除成功"); window.location.href = "channel-no.action" ; }, error : function(data) { alert("系統錯誤,刪除失敗"); } }); } }else{ alert("請選擇要刪除的記錄"); } } </script>
2,大量操作之彈出框
<a class="" id="" onclick="show_ad()" style="">設定詞</a>
<pre name="code" class="javascript">function show_ad() { var aaa = ""; jQuery("#tbl_type2 tr").each(function() { var text = $(this).children("td:first").find("input[type=checkbox]:checked"); if (text.val() != undefined) { aaa = text.val() + "," + aaa; } }); if (aaa != null && aaa != "") { alert(aaa); jQuery("#addiv1").css({ display: "block" }); jQuery("#addiv2").css("display", "block"); } else { alert("請選擇對象"); return false; }}
id為tbl_type2的table的第一個td
<pre name="code" class="html"><td class="td-check"> <input type="checkbox" name="ids" id="selectWare_<s:property value=" id "/>"value="<s:property value=" id "/>"/></td>
全選的js代碼
<pre name="code" class="javascript">//全選、反選$("#top_selectAll").click(function() { $('input[type=checkbox]').attr("checked", $(this).attr("checked") ? true: false);});
彈出框代碼
<div id="addiv1"></div><div id="addiv2" style="display:none; margin: 0px auto;top: 30%" class="pop pop_v1"> <h4> <span class="winTitle"> 大量設定 </span> <a id="closead" class="btn_cel"> 關閉 </a> </h4> <div style=" margin-top: 20px; padding-left: 50px;"> <label> <font style="font-size: 13px; color: black;"> 詞: </font> </label> <div> <s:textarea name="adindroduce" rows="10" style="width: 90%; margin-top: 5px; overflow:scroll; overflow-x:hidden; resize: none;"> </s:textarea> <br> <div style="height:10px; "> </div> </div> <br/> <br/> <input type="button" id="savecatalog" class="btn-newsearch btn_reelect2" value="保 存" style="width:72px; font- size: 12px; padding:0px;" onclick="setad();"> <input type="button" id="quxiao" class="btn-newsearch btn_reelect2" value="取 消" style="width:72px; font-size: 12px; padding:0px;"> </div></div>
儲存和取消的js代碼
</pre><pre name="code" class="javascript">function setad(){<span style="white-space:pre"></span> $("#pform").attr("action","<%=basePath%>/manage/product!updateAd.action"); $("#pform").submit(); <span style="white-space:pre"></span>return false;} $("#quxiao").click(function() { <span style="white-space:pre"></span>$("#addiv1").css("display", "none"); <span style="white-space:pre"></span>$("#addiv2").css("display", "none"); }); $("#closead").click(function(){ <span style="white-space:pre"></span>$("#addiv1").css("display", "none"); <span style="white-space:pre"></span>$("#addiv2").css("display", "none");});
</pre><pre>