I want to show a div depending of the value of a <select> option, using 2 functions hidediv() and showdiv() - it is working fine in firefox, but not in IE (tested with IE 6 and 7). <body onload="javascript:hidediv()"> DOES work in IE, but the rest does not.
Any ideas?
Thanks a lot
Tim
here is the code
----------------------------
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <script language=javascript type='text/javascript'>
Expand|Select|Wrap|Line Numbers
- function hidediv() {
- if (document.getElementById) { // DOM3 = IE5, NS6
- document.getElementById('genre_select1').style.visibility = 'hidden';
- }
- else {
- if (document.layers) { // Netscape 4
- document.genre_select1.visibility = 'hidden';
- }
- else { // IE 4
- document.all.genre_select1.style.visibility = 'hidden';
- }
- }
- }
- function showdiv() {
- if (document.getElementById) { // DOM3 = IE5, NS6
- document.getElementById('genre_select1').style.visibility = 'visible';
- }
- else {
- if (document.layers) { // Netscape 4
- document.genre_select1.visibility = 'visible';
- }
- else { // IE 4
- document.all.genre_select1.style.visibility = 'visible';
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- </script>
- </head>
- <body onload="javascript:hidediv()">
- <form name="form" action="chart.php" method="post">
- <select name="view_by">
- <option value="" onclick="hide()">-----Chart view-----</option>
- <option onclick="javascript:hidediv()">Most votes</option>
- <option onclick="javascript:hidediv()">Latest entries</option>
- <option onclick="javascript:hidediv()">Most profile views</option>
- <option onclick="javascript:hidediv()">Age</option>
- <option onclick="javascript:showdiv()">Genre</option>
- <option onclick="javascript:hidediv()">User name a-z</option>
- <option onclick="javascript:hidediv()">------------------</option>
- <option onclick="javascript:hidediv()">Non competition entries</option>
- </select>
- </select> <input type="submit" class="button" value="Go" />
- <br/>
- <div id="genre_select1"><select name="genre_select">
- <option value='1'>1</option><option value='2'>2</option> </select></div>
- </form>
- </div>
- </body>
- </html>