Reputation: 2493
I have defined a drop down list in html as follows. I have appended the values for the dropdown from javascript. The value I am trying to set is "5". But it does not work. Can someone tell me another way?
<html>
<head>
<title>Title</title>
<script type="text/javascript" src="phonegap-1.4.1.js"></script>
<script type="text/javascript" src="JS/Util.js"></script>
<script type="text/javascript" src="JS/Language.js"></script>
<script type="text/javascript">
function dropdown(){
document.getElementById("numberlist").appendChild(5);
}
</script>
</head>
<body onload="dropdown();">
<div id="main3"></div>
<select id = "numberlist"><option>12</option><option>24</option><option>36</option></select>
</body>
</html>
Upvotes: 0
Views: 5361
Reputation: 1643
Copying from the original question. Will this solve your issue?
function dropdown(){
var drp = document.getElementById("numberlist");
var optn = document.createElement("OPTION");
optn.text="3";
optn.value="3";
drp.add(optn);
}
Upvotes: 2