Home > Web Front-end > JS Tutorial > A js_javascript technique for assigning values ​​​​to controls on the page in batches

A js_javascript technique for assigning values ​​​​to controls on the page in batches

WBOY
Release: 2016-05-16 18:24:50
Original
987 people have browsed it
Copy code The code is as follows:

function SetFormValue(column,values)
{
var elem;
for(var m=0;m{
var tempValue=column[m];
elem=null;
elem=document.getElementById (tempValue);
if(elem==null)
{
//If there is no corresponding control, skip this loop
continue;
}

var trueValue=eval("values.Rows[0]." tempValue);

if(trueValue==''||trueValue=='null'||trueValue==null)
{
//If the current value is empty, skip this loop
continue;
}
if(elem.tagName=='SELECT')
{
//select control Also handle
for(var j=0;j {

if(trueValue==elem.options[j].value)
{
//Find the corresponding element and make it selected
elem.options[j].selected=true;
//Make it unselectable
elem.disabled=true;
//Exit Loop
break;
}
}
}
else if(elem.tagName=='INPUT')
{
      elem.value=trueValue;
elem .readOnly=true;
}
}
}
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