SoFunction
Updated on 2025-02-28

Common methods for Javascript select drop-down box operation


function AddDropDownList(id,fatherCtl)
{
if(!(id))
{
var ddl = ('select');
("id",id);
if(fatherCtl&&(fatherCtl))
(fatherCtl).appendChild(ddl);
else
(ddl);
}
}
//Delete the specified drop-down box
function RemoveDropDownList(id)
{
var ctl = (id);
if(ctl)
(ctl);
}
//Add options to the drop-down box
function AddDDDLOption(id,text,value)
{
var ctl = (id);
if(ctl)
{
[] = new Option(text,value);
}
}
//Delete all options
function RemoveAllDDLOptions(id)
{
var ctl = (id);
if(ctl)
{
=0;
}
}
//Delete the option to specify the index
function RemoveDDLOption(id,index)
{
var ctl=(id);
if(ctl && [index])
{
[index]=null;
}
}
//Get the value selected by the drop-down box
function GetDDLSelectedValue(id)
{
var ctl = (id);
if(ctl)
{
return [].value;
}
}
//Get the text selected by the drop-down box
function GetDDLSelectedText(id)
{
var ctl = (id);
if(ctl)
{
return [].text;
}
}