| | |
javascript mind twister
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
I have being trying to make a javascript code that will show different submenus depending on what was selected on the previous menu. Although my script has no bugs according to Internet Explorer it seems to not work in IE nor Crome. Can anybody see what's wrong with this code because it looks perfect but just doesn't work as in won't display the submenus on selection.
html Syntax (Toggle Plain Text)
<head><script language=javascript type='text/javascript'> function showprojecttype(var1) { if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById('divmodify').style.visibility = 'hidden'; document.getElementById('divcreate').style.visibility = 'hidden'; } else { if (document.layers) { // Netscape 4 document.divmodify.visibility = 'hidden'; document.divcreate.visibility = 'hidden'; } else { // IE 4 document.all.divmodify.style.visibility = 'hidden'; document.all.divcreate.style.visibility = 'hidden'; } } if (var1=='divcreate') { if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById('divcreate').style.visibility = 'visible'; } else { if (document.layers) { // Netscape 4 document.divcreate.visibility = 'visible'; } else { // IE 4 document.all.divcreate.style.visibility = 'visible'; } } } else { if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById('divmodify').style.visibility = 'visible'; } else { if (document.layers) { // Netscape 4 document.divmodify.visibility = 'visible'; } else { // IE 4 document.all.divmodify.style.visibility = 'visible'; } } } } </script></head><body onload=javascript:showprojecttype('divcreate');> <form method='post' style='margin:0px; padding:0px;' name='form1'> Modify or Create:<select name='modify||create' size=1 onchange='javascript:showprojecttype(this.options[this.selectedIndex].value);'> <option value='divcreate'> <option value='divcreate'>Create <option value='divmodify'>Modify </select><br> <select id='divmodify' name='divmodify' size=1 style='display:none;'> <option value='1'>option a <option value='1'>option b <option value='1'>option c <option value='1'>option d </select> <div id='divcreate' name='divcreate' style='display:none;'> If this text shows it probably works. </div> </form></body>
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - MacGyver Fan
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - MacGyver Fan
Silly me. I didn't follow the tutorial properly. I just found out that javascript was meant to hide the menus and not css. There for my fixed code is as follows and this topic is solved.
*Solved*
html Syntax (Toggle Plain Text)
<body> <form method='post' style='margin:0px; padding:0px;' name='form1'> Modify or Create:<select name='modify||create' size=1 onchange='javascript:showprojecttype(this.options[this.selectedIndex].value);'> <option value=''>Select <option value='divcreate'>Create <option value='divmodify'>Modify </select><br> <select id='divmodify' name='divmodify' size=1> <option value='1'>option a <option value='1'>option b <option value='1'>option c <option value='1'>option d </select> <div id='divcreate' name='divcreate'> If this text shows it probably works. </div> </form> <script language=javascript type='text/javascript'> if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById('divmodify').style.visibility = 'hidden'; document.getElementById('divcreate').style.visibility = 'hidden'; } else { if (document.layers) { // Netscape 4 document.divmodify.visibility = 'hidden'; document.divcreate.visibility = 'hidden'; } else { // IE 4 document.all.divmodify.style.visibility = 'hidden'; document.all.divcreate.style.visibility = 'hidden'; } } function showprojecttype(var1) { if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById('divmodify').style.visibility = 'hidden'; document.getElementById('divcreate').style.visibility = 'hidden'; } else { if (document.layers) { // Netscape 4 document.divmodify.visibility = 'hidden'; document.divcreate.visibility = 'hidden'; } else { // IE 4 document.all.divmodify.style.visibility = 'hidden'; document.all.divcreate.style.visibility = 'hidden'; } } if (var1=='divcreate') { if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById('divcreate').style.visibility = 'visible'; } else if (var1=='divmodify') { if (document.layers) { // Netscape 4 document.divcreate.visibility = 'visible'; } else { // IE 4 document.all.divcreate.style.visibility = 'visible'; } } } else { if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById('divmodify').style.visibility = 'visible'; } else { if (document.layers) { // Netscape 4 document.divmodify.visibility = 'visible'; } else { // IE 4 document.all.divmodify.style.visibility = 'visible'; } } } } </script></body>
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - MacGyver Fan
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - MacGyver Fan
![]() |
Similar Threads
- Help with automatic update problem and more (Viruses, Spyware and other Nasties)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Prototype js Ajax evalJSON()
- Next Thread: Loading bar
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxhelp animate automatically beta box bug calendar captcha cart checkbox child class column cookies createrange() css cursor decimal design dom download dropdown editor element engine enter error events explorer file focus form forms frameworks google gwt html htmlform ie8 iframe image() images index internet java javascript jawascriptruntimeerror jquery jsf jsfile jump listbox math matrixcaptcha menu microsoft mimic mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent pdf php player post problem progressbar prototype rated rating regex runtime scale scroll search select session shopping size sql star starrating stars text textarea validation w3c web website window windowofwords windowsxp wysiwyg xml \n






