//去除空格
String.prototype.trim = function(){
return this.replace(/(^/s*)|(/s*$)/g, "");
}
function selectallcheckbox(obj) { //全选或全不选
var tureorfalse=obj.checked;
var theDetail=document.all("MainBody").rows;
for(var i=0;i<theDetail.length;i++) {
theDetail[i].all("record_select").checked=tureorfalse;
}
}
//删除
function delDetailProcess() {
var alltbDetailUsed= document.all("MainBody").rows;
if (confirm("确定选择正确并且要将这些明细删除")==false) return false;
for(var i=0;i<alltbDetailUsed.length;i++) {
if (alltbDetailUsed[i].all("record_select").checked==true) {
document.all("MainBody").deleteRow(i);
i=i-1;
}
}
}
//增加一行 (用克隆)
function addDetailProcess() {
var newRow = document.all("Preparetable").rows[0].cloneNode(true);
document.all("MainBody").lastChild.appendChild(newRow);
}
//用插入
function addDetailProcess() {
var newtr=document.all("MainBody").insertRow(-1);
for(var y=0;y<document.all("MainBody").rows[0].cells.length+1;y++){
newtr.insertCell().innerHTML='';
}
newtr.cells[0].innerHTML="<input type='checkbox' name='record_select' value='555'>";
}
function changOption(theField){
//获取当前行号
var exrows=theField.parentNode.parentNode.rowIndex;
//将非数字字符去掉
theField.value=(theField.value.replace(/[^0-9.]/g,'')).replace(/[.][0-9]*[.]/, '.');
}
//重置
function resetForm(formName) {
var formObj = document.forms[formName];
var formEl = formObj.elements;
for (var i=0; i<formEl.length; i++) {
var element = formEl[i];
if (element.type == 'submit') { continue; }
if (element.type == 'reset') { continue; }
if (element.type == 'button') { continue; }
if (element.type == 'hidden') {
if(element.name!='method' ) {element.value = '';}
}
if (element.type == 'text') { element.value = ''; }
if (element.type == 'textarea') { element.value = ''; }
if (element.type == 'checkbox') { element.checked = false; }
if (element.type == 'radio') { element.checked = false; }
if (element.type == 'select-multiple') { element.selectedIndex = 0; }
if (element.type == 'select-one') { element.selectedIndex = 0; }
}
return false;
}