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.
Sk Imad FakirPosted Aug 14, 2018, 12:17 PM
Jignesh KumarPosted Aug 13, 2018, 9:49 AM
Nanddeep NachanPosted Aug 13, 2018, 9:43 AM
harshit vermaPosted Aug 13, 2018, 9:40 AM
Nanddeep NachanPosted Aug 13, 2018, 9:26 AM