Home > Web Front-end > JS Tutorial > body text

Method to get the original (initial) value of the form control_javascript skills

WBOY
Release: 2016-05-16 17:24:51
Original
1087 people have browsed it
Copy code The code is as follows:

var saveObject = {};//Save the changed value
function saveThisData(obj,type){//The changed data will display the original value on the right
var defaultValue, newValue, key, displayValue;
var defaultValueDisplayFont;
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 brackets and code
break ;
case 'check'://checkbox
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 enumeration 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 control
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= "     " }
}


Rendering:

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!