TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
harshit verma
NA
36
2.5k
Adding a value to a dropdown through Javascript in c#
Aug 13 2018 9:17 AM
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.
Reply
Answers (
5
)
routetable.routes.maphubs() error
login history storing