Hi,
I want to add a value to the Dropdownlist through Javascript but am getting Runtime Errors.
Below is my code, can some one help me on this. I tried multiple approches from webSearch but are not working.
function run() {
debugger;
var ddlvalue = document.getElementById("<%=ddlTest.ClientID%>");
if (ddlvalue.options[ddlvalue.selectedIndex].value == "0")
{
alert("Please select a value from the Dropdown!");
return;
}
var option = document.createElement('option');
option.text = 'UK';
option.value = '5';
ddlvalue.add(option); //Tried no error but value not getting added to Dropdown list.
document.getElementById("<%=ddlTest.ClientID%>").add(option);//Tried giving runtime error.

Nanddeep NachanRank #38 · 35.2K reputationPosted Aug 13, 2018, 5:26 AM EDT
harshit verma33 reputationPosted Aug 13, 2018, 5:40 AM EDT
Nanddeep NachanRank #38 · 35.2K reputationPosted Aug 13, 2018, 5:43 AM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Aug 13, 2018, 5:49 AM EDT
Sk Imad Fakir23 reputationPosted Aug 14, 2018, 8:17 AM EDT