Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes HTML, CSS and JavaScript and the fly likes option values are not being shown when using javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "option values are not being shown when using javascript" Watch "option values are not being shown when using javascript" New topic
Author

option values are not being shown when using javascript

puja shaw
Ranch Hand

Joined: Nov 06, 2012
Posts: 32

posted Today 17:09:20


i am stuck with a problem regarding javascript.I am trying to add an option to the select box and add a value to that option through javascript.The option is getting added but the value is not being shown in that option.I am not able to figure out where the problem lies.Can you please help me.




<html>
<body>
<select id="SelectHidden" name="SelectHiddenThing" onClick="MyFunction1();">



<select/>

<script>


function MyFunction1(){

var box=document.getElementById("SelectHidden");

var anoption=document.createElement("OPTION");


alert("*******"+anoption);

box.options.add(anoption);

anoption.innerText="two";

anoption.Value="2"

};


</script>

</body>

</html>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: option values are not being shown when using javascript
 
Similar Threads
document.getElementById() not working
Help needed with onChange()
unable to access the values of dynamically newly added rows to table
DOM and adding a brand new select list
Dynamic drop down box