aspose file tools*
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 Spring in Action this week in the Spring 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>
 
jQuery in Action, 2nd edition
 
subject: option values are not being shown when using javascript