Batch Data Input, auxiliary data input, and Related detection (jscript client) (original)
Author: Xiao Yue mark
Related Links: batch data input, auxiliary data input, and Related detection (ASP server) (original)
<Script language = "jscript"> <! -- // Press enter to replace the tab. When a button is displayed, the function keydown () {If (event. keycode = 13) {// check the style name, whether it is a button if (event. srcelement. classname = "fbtclass") return true; event. keycode = 9; return true ;}} document. onkeydown = keydown; var myform; // The total number of batch records to facilitate the detection of user input var inttotal = <% = intbilltotal %>; // initialize the webpage form project function Init (form) {myform = form; formsum () ;}// use the IE web page dialog box (mode) to assist in data input function openwin (intid) {var arrv Alue = Window. showmodaldialog ("<% = gbl1_str_sys_root_path %> winfo/product_wlist.asp? At = 1 & 1 "); If (arrvalue! = NULL) & (arrvalue. Length = 6) {var id = isnan (parseint (arrvalue [0])? 0: parseint (arrvalue [0]); If (ID = 0) return; // only one line of for (VAR I = 1; I <= inttotal; I ++) {If (isnan (parseint (myform ["fih_pid _" + I]. value ))? 0: parseint (myform ["fih_pid _" + I]. value) = ID) {alert ("data of this product has been entered. To change the data, modify it directly in the form! "); Return ;}try {myform [" fih_pid _ "+ intid]. value = arrvalue [0]; myform ["fih_pmodel _" + intid]. value = arrvalue [1]; myform ["fih_pvalue _" + intid]. value = arrvalue [2]; myform ["fih_pspec _" + intid]. value = arrvalue [3]; myform ["fih_punit _" + intid]. value = arrvalue [4]; myform ["fih_pprice _" + intid]. value = filternum (arrvalue [5], 2); myform ["fih_ptotal _" + intid]. value = "0.00"; myform ["fih_pcost _ "+ Intid]. value =" 0.00 ";} catch (e) {alert (" An error occurred while filling the form! ") ;}} Else {clearrow (intid) }} function enterdown () {If (event. keycode = 13) Return (event. srcelement. tagname = "textarea ")? True: false);} // reset the form function formreset (form) {var flag = confirm ("are you sure you want to cancel all operations and return the initial value? "); If (FLAG) {form. reset () ;}/// submit form function formsubmit (form) {If (formsubmitcheck () & confirm ("are you sure you want to submit data? ") {Form. submit () ;}// detection data function formsubmitcheck () {var flag = false; var id = 0; For (VAR I = 1; I <= inttotal; I ++) {id = isnan (parseint (myform ["fih_pid _" + I]. value ))? 0: parseint (myform ["fih_pid _" + I]. Value); If (ID> 0) {flag = true; break ;}} if (! Flag) Alert ("Empty data cannot be submitted! "); Return flag;} // total function formsum () {var totalsum = 0; For (VAR I = 1; I <= inttotal; I ++) {If (isnan (parseint (myform ["fih_pid _" + I]. value ))? 0: parseint (myform ["fih_pid _" + I]. value) = 0) continue; totalsum + = isnan (parsefloat (myform ["fih_pcost _" + I]. value ))? 0: parsefloat (myform ["fih_pcost _" + I]. value);} myform. fit_totalprice.value = filternum (totalsum, 2); window. setTimeout ("formsum ()", 200);} // calculates the total amount of rows. Function sumrow (ID) {var intid = isnan (parseint (myform ["fih_pid _" + id]. value ))? 0: parseint (myform ["fih_pid _" + id]. value); If (intid <= 0) {clearrow (ID) return;} var num = filternum (myform ["fih_ptotal _" + id]. value, 2); var price = filternum (myform ["fih_pprice _" + id]. value, 2); If (price <0) {alert ("the unit price cannot be negative! "); Price = math. ABS (price); myform ["fih_pprice _" + id]. value = price;} var spec = eval (myform ["fih_pspec _" + id]. value); var spec = isnan (parsefloat (SPEC ))? 1: filternum (SPEC, 2); var cost = num * price * spec; myform ["fih_ptotal _" + id]. value = num; myform ["fih_pprice _" + id]. value = price; myform ["fih_pcost _" + id]. value = filternum (cost, 2);} // clear a row of data function clearrow (ID) {myform ["fih_pid _" + id]. value = 0; myform ["fih_pmodel _" + id]. value = ""; myform ["fih_pvalue _" + id]. value = ""; myform ["fih_pspec _" + id]. value = ""; myform ["fih_punit _" + I D]. value = ""; myform ["fih_pprice _" + id]. value = ""; myform ["fih_ptotal _" + id]. value = ""; myform ["fih_pcost _" + id]. value = "";} // format the number function filternum (Num, k) {var num = isnan (parsefloat (Num ))? 0: parsefloat (Num); try {return num. tofixed (k);} catch (e) {alert ("the script engine does not support this operation. Please upgrade your browser to ie5.5 or above! "); Return 0 ;}/// checks the vbs Date Format function isvbdate (STR) {// The minimum year var miny = 2000; // The maximum year var Maxy = 2005; vaR Reg =/^ (/d {4}) (-| // | /.) (/d {1, 2})/2 (/d {1, 2}) $/; Result = Str. match (REG); If (result = NULL) return false; var y, M, D; // obtain the year of user input y = Result [1]; // obtain the month input by the user. M = parseint (result [3]); // obtain the Date input by the user. d = parseint (result [4]); if (Y> Maxy) | (Y <miny) {alert ("the year cannot exceed (" + miny + "-" + Maxy +") Range! "); Return false;} If (M <1) | (M> 12) | (d <1) | (D> 31) return false; if (M = 4) | (M = 6) | (M = 9) | (M = 11 )) & (d> 30) return false; If (Y % 4) = 0) {If (M = 2) & (d> 29 )) return false;} else {If (M = 2) & (d> 28) return false;} return true ;} // checks the vbs Date Format function checkvbdate (input) {If (input. value = "") return; If (! Isvbdate (input. value) {alert ("the date format is incorrect, please input again"); input. focus (); input. select () ;}// the IE web page dialog box (mode) assists in inputting the customer data function browsecostmer () {var arrvalue = Window. showmodaldialog ("<% = gbl1_str_sys_root_path %> winfo/costmer_wlist.asp"); If (arrvalue! = NULL) & (arrvalue. Length = 2) {var id = isnan (parseint (arrvalue [0])? 0: parseint (arrvalue [0]); var costmer = arrvalue [1]; myform. fit_custid.value = ID; myform. fit_custname.value = costmer; }}// --> </SCRIPT>