Method _ javascript skills

Source: Internet
Author: User
The original value of the form control is more practical in some cases. The specific method is as follows. If you are interested, refer to it and hope to help you. The Code is as follows:


Var saveObject ={}; // Save the changed Value
Function saveThisData (obj, type) {// The original value is displayed on the right of the data that generates the change.
Var defaultValue, newValue, key, displayValue;
Var defavaluvaluedisplayfont;
Switch (type ){
Case 'select': // Ext drop-down box
DefaultValue = obj. originalValue. split (']') [0]. substring (1 );
NewValue = obj. value;
Key = obj. id;
DefaultValueDisplayFont = obj. container. dom. getElementsByTagName ("font") [0];
DisplayValue = obj. originalValue. substring (defaultValue. length + 2); // remove parentheses and code
Break;
Case 'check': // check box
Key = obj. name;
DefaultValueDisplayFont = obj. parentElement. getElementsByTagName ("font") [0];
DefaultValue = obj. defaultChecked;
If (defaultValue ){
DisplayValue = 'yes ';
} Else {
DisplayValue = 'no ';
}
If (obj. checked ){
NewValue = 1;
} Else {
NewValue = 0;
}
Break;
Case 'rq': // Ext date object
Key = obj. name;
DefaultValueDisplayFont = obj. parentElement. parentElement. getElementsByTagName ("font") [0];
DefaultValue = obj. defaultValue;
NewValue = obj. value;
DisplayValue = defaultValue;
Break;
Case 'enum': // Ext-encapsulated enumerated drop-down box object
Key = obj. id;
DefaultValue = obj. startValue;
NewValue = obj. value;
DisplayValue = obj. originalValue;
DefaultValueDisplayFont = obj. container. dom. getElementsByTagName ("font") [0];
Break;
Default:
If (arguments [2]! = Null) {// year and month controls
Var monthFieldid = obj. container. dom. id. split ("_") [1];
Key = monthFieldid;
DefaultValue = Ext. getDom ('sccjgzny '). defaultValue;
NewValue = Ext. getDom ('sccjgzny '). value;
Var yy = defaultValue. substring (0, 7 );
DisplayValue = yy. replace ('-', 'Year') + 'month ';
DefaultValueDisplayFont = Epx. get (monthFieldid). container. dom. getElementsByTagName ("font") [0];
}
Else {
Key = obj. name;
DefaultValueDisplayFont = obj. parentElement. getElementsByTagName ("font") [0];
DefaultValue = obj. defaultValue;
NewValue = obj. value;
DisplayValue = defaultValue;
}
Break;
}
SaveObject [key] = newValue;
If (defaultValue! = NewValue ){
If (defaultValue = ''& type! = 'Check '){
DefaultValueDisplayFont. innerHTML = "";
} Else {
DefaultValueDisplayFont. innerHTML = displayValue;
}
} Else {
DefaultValueDisplayFont. innerHTML = '';
Delete saveObject [key];
}
}


:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.