Binding Data DropdownList using Javascript

in code HTML

select id=”dropDown”

Write function
function appendOption(listID, optionText, optionValue)
  var newOption = document.createElement('option');
  newOption.text = optionText;
  newOption.value = optionValue;
  var list = document.getElementById(listID);
  try {
    list.add(newOption, null); // standards compliant; doesn't work in IE
  catch(ex) {
    list.add(newOption); // IE only
After write functions in Page Load :

function pageLoad(sender,e) {
var _drop=document.getElementById(").value;
   var _listItem=_drop.split(',');
   for(var i=0;i<_listItem.length;i++)
       appendOption('dropDown', _listItem[i], _listItem[i]);    

Leave a Reply

Please log in using one of these methods to post your comment: Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: