Filling Dropdown using Javascript
-
Hi, I am filling the dropdown using javascript. I have given the selected index also. But after any server event the filled values are gone. What could be the reason. Thanks.
-
Hi, I am filling the dropdown using javascript. I have given the selected index also. But after any server event the filled values are gone. What could be the reason. Thanks.
newOpt = document.createElement("OPTION"); newOpt = new Option(nodval,nodval); libox.options.add(newOpt); try this..
-
-
newOpt = document.createElement("OPTION"); newOpt = new Option(nodval,nodval); libox.options.add(newOpt); try this..
-
Hi, Thanks. I have used that option only. But still after the postback the filled items gone.
send me your code
-
send me your code
var ddlVendor = window.opener.document.getElementById(gId); //Clears the combo box contents. for (var count = ddlVendor.options.length-1; count >-1; count--) { ddlVendor.options[count] = null; } var vendorNodes = listNode.getElementsByTagName('Table1/Name'); var vendorIds = listNode.getElementsByTagName('Table1/Id'); var textValue; var idValue; var optionItem; //Add new vendors list to the vendors combo box. for (var count = 0; count < vendorNodes.length; count++) { textValue = GetInnerText(vendorNodes[count]); idValue = GetInnerText(vendorIds[count]); var newOption = window.opener.document.createElement('OPTION'); newOption.text = textValue; newOption.value = idValue; ddlVendor.options.add(newOption); } ddlVendor.selectedIndex = count-1;
-
var ddlVendor = window.opener.document.getElementById(gId); //Clears the combo box contents. for (var count = ddlVendor.options.length-1; count >-1; count--) { ddlVendor.options[count] = null; } var vendorNodes = listNode.getElementsByTagName('Table1/Name'); var vendorIds = listNode.getElementsByTagName('Table1/Id'); var textValue; var idValue; var optionItem; //Add new vendors list to the vendors combo box. for (var count = 0; count < vendorNodes.length; count++) { textValue = GetInnerText(vendorNodes[count]); idValue = GetInnerText(vendorIds[count]); var newOption = window.opener.document.createElement('OPTION'); newOption.text = textValue; newOption.value = idValue; ddlVendor.options.add(newOption); } ddlVendor.selectedIndex = count-1;
check the for loop....length and count condition..
-
If you are using .net 2.0 or higher. I suggest using AJAX and writing server code to populate the drop down. Do you understand why it is that if you populate a dropdown with javascript you're going to have to re-populate that list after every postback?
I didn't get any requirements for the signature
-
Hi, I am filling the dropdown using javascript. I have given the selected index also. But after any server event the filled values are gone. What could be the reason. Thanks.
Mahesh.J wrote:
any server event
The server event resurrects the values from a statebag called ViewState. You ought to rebind your JavaScript dropdown again.
Vasudevan Deepak Kumar Personal Homepage
Tech Gossips
All the world's a stage, And all the men and women merely players. They have their exits and their entrances; And one man in his time plays many parts... --William Shakespeare