Home > ASP.Net > Filling Dropdown List from XMLHTTP response

Filling Dropdown List from XMLHTTP response


Hi
Following function is to fill dropdownlist (TEXT and VALUE) from the response we get from handler file. Just pass dropdown ID and the string in this function. 

function FN_fillList(ddl,str){
        var arr = str.split(”;”);
        //To Remove All Items of Drop Down
       document.getElementById(ddl).length = 0;
        document.getElementById(ddl).options[0] = new Option(’Select’,0);
        //To Add Items In Drop Down
        for(var i=1,j=1; i < arr.length;i=i+2,j++){
            document.getEle mentById(ddl).options[j] = new Option(arr[i],arr[i+1]);
       }
    }

Good Luck

Advertisements
Categories: ASP.Net
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: