home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2005 February
/
PCWorld_2005-02_cd.bin
/
komunikace
/
slim
/
sbsetup.exe
/
FillFormField.js
< prev
next >
Wrap
Text File
|
2003-05-28
|
1KB
|
43 lines
function FillFormField(vDoc,vFormIndex,vName,vValue)
{
var form=vDoc.forms[vFormIndex];
if (form==null) return false;
var elem=form.elements[vName];
var tn;
if (elem==null) return false;
if (elem.tagName==null)
{
if (elem.length!=null)
{
var col=elem;
for (var i=0;i<col.length;i++)
{
elem=col[i];
tn=elem.tagName.toLowerCase();
if (tn=="radio") return false;
elem.checked=(vValue==elem.value);
}
return true;
}
return false;
}
tn=elem.tagName.toLowerCase();
if (tn=="input")
{
var t=elem.type;
if (t=="text" || t=="password") elem.value=vValue;
else if (t=="radio" || t=="checkbox") elem.checked=(vValue==elem.value);
}
else if (tn=="select")
{
for (var i=0; i< elem.options.length;i++)
{
if (elem.options[i].value!="") elem.options[i].selected=(elem.options[i].value==vValue);
else elem.options[i].selected=(elem.options[i].text==vValue);
}
}
else if (tn=="textarea") elem.value=vValue;
else return false;
return true;
}