1. 模态对话框打开信息画面 function openProcessInfoDialog(masterID) { var url = "../maintenancemng/processInfoDetail.aspx?MasterID=" + masterID + "&servicesId=" + $("#hd_id").val(); var us = window.showModalDialog(url, window, "dialogHeight:768px;dialogWidth:810px"); if (us != null && typeof (us) != undefined && us == "1") { //window.location.href = "../services/servicesDetail.aspx?MasterID=" + $("#hd_id").val(); window.location.reload(); } } 2. 数量正则判断 function IsUnitFormat(inString) { var par = /^[0-9]*[1-9][0-9]*$/; if (par.test(inString)) { return true; } else { return false; } } 3.删除信息 function deleteInfo(tablename) { var table = document.getElementById(tablename); var tr = table.getElementsByTagName("tr"); for (i = 1; i < tr.length; i++) { var td = tr[i].getElementsByTagName("td"); var checkbox = td[0].children[0]; if (checkbox.checked) { if (confirm("是否确定删除所选数据!")) { return true; } else { return false; } } } alert("请选择要删除的数据!"); return false; } 4.全选 function selectAll(tablename) { var table = document.getElementById(tablename); var tr = table.getElementsByTagName("tr"); var th = tr[0].getElementsByTagName("td"); var checkbox = th[0].children[0]; var selected = checkbox.checked; for (i = 1; i < tr.length; i++) { var td = tr[i].getElementsByTagName("td"); checkbox = td[0].children[0]; checkbox.checked = selected; } } 5.新增信息 function addComplaintInfo() { var url = "../maintenancemng/complaintInfoDetail.aspx?editMode=2&servicesId=" + $("#hd_id").val(); var us = window.showModalDialog(url, window, "dialogHeight:768px;dialogWidth:1024px"); if (us != null && typeof (us) != undefined && us == "1") { window.location.reload(); return true; } return false; } 6.新增行时用到 var index = 0; var reRow = 0; var insertRow; //新增一行 function addTemp() { var t = document.getElementById("gridDisassemblepartsPageResult"); var newTr = t.insertRow(t.rows.length); index++; newTr.id = index; newTr.onmouseover = function () { this.style.background = "#eee"; } newTr.onmouseout = function () { this.style.background = "#fff"; } newTr.style.cursor = "pointer"; newTr.className = "d1"; var newTd0 = newTr.insertCell(); newTd0.style.width = "20px"; var newTd1 = newTr.insertCell(); newTd1.style.width = "200px"; var newTd2 = newTr.insertCell(); newTd2.style.width = "100px"; var newTd3 = newTr.insertCell(); newTd3.style.width = "90px"; var newTd4 = newTr.insertCell(); newTd4.style.width = "90px" var newTd5 = newTr.insertCell(); newTd5.style.display = "none"; var newTd6 = newTr.insertCell(); newTd6.style.display = "none"; var newTd7 = newTr.insertCell(); newTd7.style.display = "none"; var newTd8 = newTr.insertCell(); newTd8.style.display = "none"; var newTd9 = newTr.insertCell(); newTd9.style.display = "none"; var id1 = "<input type='text' name='txtMaterialID' disabled ='disabled' value='' style='width:79%;text-align:left;margin-left:14px;' class='noemptyInput' /> "; var id2 = "<input type='button' id ='selectPartsCode' name='selectPartsCode' value='' class='look_up' onclick='ShowOpenBP(" + index + ");' /> "; newTd0.innerHTML = "<input type='checkbox' id='cbSelected' style='width:98%'/>"; newTd1.innerHTML = id1 + id2; newTd2.innerHTML = "<input type='text' name='txtMaterialname' disabled='disabled' style='width:98%; text-align:left;' value='' class='noemptyInput'>"; newTd3.innerHTML = "<input type='text' name='txtSnnum' value='' id='txtSnnum' class='noemptyInput' style='width:98%;text-align:left;' disabled='disabled'>"; newTd4.innerHTML = "<input type='text' name='txtQty' value='1' id='txtQty' disabled='disabled' class='noemptyInput' style='width:98%;text-align:right;' maxlength='5'>"; //隐藏字段 newTd5.innerHTML = "<input type='text' name='MaterialID' value=''>"; newTd6.innerHTML = "<input type='text' name='Materialcode' value=''>"; newTd7.innerHTML = "<input type='text' name='Materialname' value=''>"; newTd8.innerHTML = "<input type='text' name='Snnum' value=''>"; newTd9.innerHTML = "<input type='text' name='Qty' value='1'>"; } 6.删除选择行 function deleteTemp(obj) { var ids = obj; deleteFlash(ids); //customer.js } //删除所有 function deleteAllTemp() { var count = 0; var table; var tr; var td; var checkbox; if (confirm(Resource("lbl_delete2"))) { table = document.getElementById("gridDisassemblepartsPageResult"); tr = table.getElementsByTagName("tr"); rowCount = tr.length; for (i = 1; i < rowCount; i++) { td = tr[i].getElementsByTagName("td"); checkbox = td[0].children[0]; if (checkbox.checked) { // if (td[6].children[0].value !="") { // document.getElementById("hd_consumedpartslist").value += td[6].children[0].value +"$";//用于后台进行删除操作 、这里也很中要,平常都是用隐藏域把前台的值传到后台C#代码来处理 // } table.deleteRow(i); i--; rowCount--; count++; } } if (count < 1) { alert(Resource("lbl_delete1")); } } else { ids = ""; } } 7.查询部品 function searchBPBM(url, height, width, txtID, hid1ID,snnum,materCodeId, materialcode,materialname,qty1) { var obj = new Object(); obj.materialType = "1"; // 查询部品 var us = window.showModalDialog(url, obj, "dialogHeight:" + height + "px;dialogWidth:" + width + "px"); if (us != null && typeof (us) != undefined) { var ls = us.split(','); if (ls[0] == "remove") { $(txtID).val(""); $(hid1ID).val(""); $(snnum).val(""); $(materCodeId).val(""); $(materialcode).val(""); $(materialname).val(""); $(qty1).val(""); } else { $(txtID).val(ls[1]);//部品代码 $(hid1ID).val(ls[2]); //部品名称 $(materCodeId).val(ls[0]); //部品代码对应的ID $(materialcode).val(ls[1]); //部品代码 $(materialname).val(ls[2]); //部品名称 $(qty1).val("1"); debugger; UpdateSnnum(ls[0], ls[1], $(snnum)); } } } //部品编码lookup弹出框 function ShowOpenBP(index) { var tr = document.getElementById("gridDisassemblepartsPageResult").getElementsByTagName("tr"); for (i = 1; i < tr.length; i++) { if (tr[i].id == index) { var td = tr[i].getElementsByTagName("td"); var txtID = td[1].children[0]; //部品代码 var hid1ID = td[2].children[0]; //部品名称 var snnum = td[3].children[0]; //S/N号 var materCodeId = td[5].children[0]; //部品代码对应的ID var materialcode = td[6].children[0]; //部品代码 var materialname = td[7].children[0]; //部品名称 var qty1 = td[9].children[0]; //数量 break; } } searchBPBM('../lookup/lookMaterialCode.aspx', 450, 800, txtID, hid1ID,snnum,materCodeId, materialcode,materialname,qty1); } 8.customer.js function delete_click() { var ids = ""; //id以,隔开 var ls = document.getElementsByTagName("input"); if (ls.length > 0) { for (var i = 0; i < ls.length; i++) { var ele = ls[i]; if (ele.type == "checkbox" && ele.id.indexOf("chkl") > 0 && ele.title != "all") { if (ele.checked) { ids += ele.value + ","; } } } if (ids.length < 1) { alert(Resource("lbl_delete1")); } else { if (confirm(Resource("lbl_delete2"))) { return ids; } else { ids = ""; } } } return ids; } function delete_Info(name, url) { var ids = delete_click(); if (ids != "" && typeof (ids) != undefined) { $.get("http://www.cnblogs.com/handle/Handle_Delete.aspx?t=" + name + "&ids=" + ids + "&r=" + Math.random(), function(result) { if (result == "success") { //alert(Resource("lbl_delete3")); window.location.href = url; } else { alert(Resource("lbl_delete4")); return "fail"; } }); } return ids; } function deleteFlash(ids) { if (ids == "fail") { return; } var ls = ids.split(','); var l = ls.length; for (var i = 0; i < l; i++) { $("tr[id='" + ls[i] + "']").remove(); } } function ck_click_1(obj,j) { var flag = 0; var ls = document.getElementsByTagName("input"); for (var i = 0; i < ls.length; i++) { var ele = ls[i]; if (ele.type == "checkbox" && ele.id.indexOf("chkl") && ele.title != "all") { if (!ele.checked) { flag = 1; break; } } } if (flag == 0) { document.getElementsByName("chkall_"+j)[0].checked = true; //document.getElementById("chkall").checked = true; } } function selectAll_1(chkall, j) { var thetable = chkall.ownerDocument; var chkList = thetable.getElementsByTagName("input"); for (var i = 0; i < chkList.length; i++) { var ele = chkList[i]; if (ele.type == "checkbox" && ele.title==""+j+"" && ele.id.indexOf("chk"+j)) { ele.checked = chkall.checked; } } } function delete_click_j(j,name) { var ids = ""; //id以,隔开 var ls = document.getElementsByTagName("input"); if (ls.length > 0) { for (var i = 0; i < ls.length; i++) { var ele = ls[i]; if (ele.type == "checkbox" && ele.title==j+"" && ele.title != "all") { if (ele.checked) { ids += ele.value + ","; } } } if (ids.length < 1) { alert(Resource("lbl_delete1")); } else { if (confirm(Resource("lbl_delete2"))) { return ids; } else { ids = ""; } } } return ids; } function delete_click_j_info(j,name) { var ids = delete_click_j(j, name); if (ids != "" && typeof (ids) != undefined) { $.get("../handle/Handle_Delete.aspx?t=" + name + "&ids=" + ids + "&r=" + Math.random(), function(result) { if (result == "success") { //alert(Resource("lbl_delete3")); window.location.href = window.location.href; return "yes"; } else { alert(Resource("lbl_delete4")); return "fail"; } }); } return "no"; } function _showModalDialog(url,height,width,flash) { if (flash) { var r = window.showModalDialog(url, window, "dialogHeight:" + height + "px;dialogWidth:" + width + "px"); if (r == "1") { window.location.href = window.location.href; //刷新当前页面 return r; } else if (r == "2") { window.parent.location.reload(); //刷新父页面 } } else { window.showModalDialog(url, window, "dialogHeight:" + height + "px;dialogWidth:" + width + "px"); } } function SelectIds() { var ids = ""; //id以,隔开 var ls = document.getElementsByTagName("input"); if (ls.length > 0) { for (var i = 0; i < ls.length; i++) { var ele = ls[i]; if (ele.type == "checkbox" && ele.id.indexOf("chkl") > 0 && ele.title != "all") { if (ele.checked) { ids += ele.value + ","; } } } if (ids.length < 1) { alert("请选择要操作的数据!"); } } return ids; } function ResetPassword() { var ids = SelectIds(); if (ids != "" && typeof (ids) != undefined) { $.get("../handle/Handle_Delete.aspx?t=resetPwd&ids=" + ids + "&r=" + Math.random(), function(result) { if (result == "success") { alert("重置成功!"); window.location.href = window.location.href; } else { alert(result); } }); } } function loadtop(text) { try{ window.parent.document.all.TopFrame.contentWindow.document.getElementById("sptxt").innerHTML = text; }catch(e){ } } function autoDiv() { $(".div_visible").each(function() { if ($(this).html() == "") { $(this).hide(); } }); } function GetUrl(url) { if (url.indexOf("?") >= 0) { if (url.indexOf('r=') >= 0) { var ls = url.split('&'); var url = ''; var l = ls.length; for (var i = 0; i < l; i++) { if (ls[i].indexOf('r=') < 0) { url += ls[i] + '&'; } } url += 'r='+Math.random(); } else { url += "&r=" + Math.random(); } } else { url += "?r="+Math.random(); } return url; } function selectAll(chkall) { var thetable = chkall.ownerDocument; var chkList = thetable.getElementsByTagName("input"); for (var i = 0; i < chkList.length; i++) { var ele = chkList[i]; if (ele.type == "checkbox" && ele.id.indexOf("chkl")) { ele.checked = chkall.checked; } } } 9.滚动条处理: <form id="form1" runat="server" submitdisabledcontrols="true" onsubmit="return startPB()"> generatePB('正在处理中,请稍候 ...'); progressBar.js : //var t_id = setInterval(animate,10); var t_id=''; var pos=0; var dir=2; var len=0; function startPB() { t_id= setInterval(animate,10); var targelem = document.getElementById('loader_container'); targelem.style.display='block'; targelem.style.visibility='visible'; return true; } function animate() { var elem = document.getElementById('progress'); if(elem != null) { if (pos==0) len += dir; if (len>32 || pos>179) pos += dir; if (pos>179) len -= dir; if (pos>179 && len==0) pos=0; elem.style.left = pos; elem.style.width = len; } } function remove_loading() { this.clearInterval(t_id); var targelem = document.getElementById('loader_container'); if(targelem) { targelem.style.display='none'; targelem.style.visibility='hidden'; } } function generatePB(txtShow) { var divPB = " <div id='loader_container' >"; divPB = divPB.concat(" <div id='top'>"); divPB = divPB.concat(" </div>"); divPB=divPB.concat(" <div id='bottom'>"); divPB=divPB.concat(" <div align='center'>"); divPB=divPB.concat( txtShow); divPB=divPB.concat(" <br>");; divPB=divPB.concat(" </div>"); divPB=divPB.concat(" <div id='loader_bg'>"); divPB=divPB.concat(" <div id='progress'> </div>"); divPB=divPB.concat(" </div>"); divPB=divPB.concat(" </div>"); divPB=divPB.concat("</div>"); document.write(divPB); remove_loading(); } function showPB(txtShow) { generatePB(txtShow); startPB(); }