Batch data entry, secondary input data, and related detection (JScript client) (original)
Author: Xiao Yuehen
Related links: Batch data entry, secondary input data, and related detection (ASP server) (original)
// Enter instead of Tab, when you encounter a button, execute the button action
Function KeyDown ()
{
Event.keycode == 13)
{
// Detect the style name, indeed whether it is a button
if (event.srcelement.classname == "fbtclass") Return True;
Event.Keycode = 9;
Return True;
}
}
Document.onkeydown = keydown;
Var myform;
// Batch record total, easy to detect user input
Var INTTOTAL = <% = INTBILLTOAL%>
// Initialize the web form project
Function init (form)
{
MyForm = form;
Formsum ();
}
// Auxiliary input data with the IE web dialog (mode)
Function OpenWin (intID)
{
Var Arrvalue = WINDOW.SHOWMODALDIALOG ("<% = GBL__STR_SYS_ROOT_PATH%> WINFO / PRODUCT_WLIST.ASP? AT = 1 & 1");
IF ((ArrValue! = null) && (arrvalue.length == 6))
{
VAR ID = isnan (paraSeint (arrvalue [0]))? 0: parseint (ArrValue [0]);
IF (id == 0) return;
// A product can only be lost
FOR (var i = 1; i <= inttotal; i )
{
IF ((ISNAN (Parseint (MyForm ["FiH_PID_" i] .value))? 0: Parseint (MyForm [FiH_PID_ " i] .value)) == ID)
{
Alert ("Enter this product data, if you need to change the data, please modify directly in the form!");
Return;
}
}
Try
{
MyForm ["FiH_PID_" INTID] .value = arrralue [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 ("Forms Filling!");
}
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 ("Do you really want to undo all your actions and return the initial value?");
IF (flag) {
Form.reset ();
}
}
//submit Form
Function Formsubmit (Form)
{
IF (Formsubmitcheck () && confirm ("OK SUM?")) {
Form.submit ();
}
}
//Test 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 (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 = filnernum (Totalsum, 2);
WINDOW.SETTIMEOUT ("Formsum ()", 200);
}
/ / Total number of calculations
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 = filnernum (MyForm ["FiH_Ptotal_" ID] .value, 2);
VAR Price = filnernum (MyForm ["FiH_Pprice_" ID] .value, 2); if (Price <0)
{
Alert ("Unparalleled unit!");
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);
}
/ / Empty 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_" ID] .value = ""
MyForm ["FiH_pprice_" id] .value = "
MyForm ["FiH_Ptotal_" ID] .value = "";
MyForm ["FiH_PCOST_" ID] .value = ""
}
/ / Formatting numbers
Function Filternum (Num, K)
{
VAR NUM = Isnan (Parsefloat (NUM))? 0: Parsefloat (NUM);
Try {
Return Num.tofixed (k);
}
Catch (e) {
Alert ("Script Engine does not support this, please upgrade your browsing to IE5.5 or more!");
Return 0;
}
}
// Detect VBS date format
Function isvbdate (STR)
{
// minimum year
VAR miny = 2000;
// 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;
// Get the year of the user input
Y = result [1];
// Get the month of user input
m = parseint (Result [3]);
/ / Get the day of the user input
D = PARSEINT (Result [4]);
IF (Y> Maxy) || (Y { Alert ("Year can't be exceeded (" 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; } // Detect VBS date format Function Checkvbdate (Input) { IF (Input.Value == ") RETURN; IF (! isvbdate (input.value)) { Alert ("Date format is incorrect, please re-enter"); INPUT.FOCUS (); INPUT.SELECT (); } } // Assist the customer data with the IE web dialog box (mode) Function browsecostmer () { Var Arrvalue = WINDOW.SHOWMODALDIALOG ("<% = GBL__STR_SYS_ROOT_PATH%> WINFO / COSTMER_WLIST.ASP"); IF (ArrValue! = null) && (arrvalue.length == 2))) { VAR ID = isnan (paraSeint (arrvalue [0]))? 0: parseint (ArrValue [0]); Var costmer = arrvalue [1]; MyForm.fit_custid.value = ID; MyForm.fit_custname.value = costmer; } } // -> script>