Thank you in advance for any help you may be able to provide!
I have created a simple example of some javascript that hides and unhides options in an HTML select box.
For some reason this code only seems to work in Firefox and not IE.
Since the select menu on my live site is dynamically created and potentially with many (Hundred) items, I cannot give each option in the select menue a unique ID and refernce it that way.
If you tell me how to get this simple example to work in IE you will be my hero!
<html>
<head>
<script language=javascript>
function hideMenuItem() {
var menu = document.getElementById("selectMenu");
menu.options.item(2).style.display = "none";
}
function resetMenuItems() {
var menu = document.getElementById("selectMenu");
menu.options.item(2).style.display = "block";
}
</script>
</head>
<body>
<form>
<select multiple id="selectMenu">
<option value ="1">1</option>
<option value ="2">2</option>
<option value ="3">3</option>
<option value ="4">4</option>
</select>
<input type=button value="Hide Menu option" onclick="hideMenuItem();">
<input type=button value="Reset Menu options" onclick="resetMenuItems();">
</form>
</body>
</html>
I have created a simple example of some javascript that hides and unhides options in an HTML select box.
For some reason this code only seems to work in Firefox and not IE.
Since the select menu on my live site is dynamically created and potentially with many (Hundred) items, I cannot give each option in the select menue a unique ID and refernce it that way.
If you tell me how to get this simple example to work in IE you will be my hero!
<html>
<head>
<script language=javascript>
function hideMenuItem() {
var menu = document.getElementById("selectMenu");
menu.options.item(2).style.display = "none";
}
function resetMenuItems() {
var menu = document.getElementById("selectMenu");
menu.options.item(2).style.display = "block";
}
</script>
</head>
<body>
<form>
<select multiple id="selectMenu">
<option value ="1">1</option>
<option value ="2">2</option>
<option value ="3">3</option>
<option value ="4">4</option>
</select>
<input type=button value="Hide Menu option" onclick="hideMenuItem();">
<input type=button value="Reset Menu options" onclick="resetMenuItems();">
</form>
</body>
</html>