The following method will help to remove one option in the Drop down by sending the Description in the Drop down.
Function Arguments
dd:- The Drop down object
dsc:- the description in the drop down which is to be deleted.
function removeOptionDsc(dd,dsc){
for (var i = 0; i < dd.options.length; i++){
var opt = dd.options[i];
if(opt.childNodes(0).data==dsc){
dd.options[i]=null;
}
}
}
Example:
If one dropdown id is "users" with data
- Asker Ali M
- Haris M
- BrickRed
- Horizon
var ddObject= document.getElementById("users");
removeOptionDsc(ddObject,"Asker Ali M");
Then the dropdown will be
- Haris M
- BrickRed
- Horizon
2.To remove an Option by passing DropdownId.
Function Arguments
dd:- The Drop down object
val:- the option id which is to be deleted.
function removeOption(dd,val){
for (var i = 0; i < dd.options.length; i++){
var opt = dd.options[i];
if(opt.value==val){
dd.options[i]=null;
}
}
}
3.How get the description of the Option by passing optionId.
Function Arguments
dd:- The Drop down object
val:- the option id to retrieve the DescriptionReturn type:
Description String.
function getDDDsc(dd,val){
for (var i = 0; i < dd.options.length; i++){
var opt = dd.options[i];
if(opt.value==val){
return opt.childNodes(0).data;
}
}
}
4.How to clear a DropDown
Function Arguments
dd:- The Drop down object
function clearDD(dd){
if(dd==null) return;
var size = dd.options.length;
for (q = size; q >= 0; q--)
{
dd.options[q]=null;
}
}
1 comment:
Please Specify the Status
xmlObj.readyState
0: not initialized.
1: connection established.
2: request received.
3: answer in process.
4: finished.]
Post a Comment