Log in

View Full Version : Menu Selection to show a div box



thecraigmcrae
07-25-2005, 04:24 PM
I'm trying to get my menu to show a div box depending on which option is selected. I had two "hidden" div boxes with text in them, and when i select option 1 i would like that corresponding div to appear, but if i select another i would like to make sure all other divs are hidden and show the correct box. Any ideas?

Twey
07-25-2005, 05:14 PM
http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm

For manual reference, to hide a div, you set document.getElementById("divid").style.display to "none." To unhide the div, set it to "block."

thecraigmcrae
07-25-2005, 05:16 PM
I saw that, but the problem is getting an option in a menu (drop-down) to begin the event.

Twey
07-25-2005, 07:41 PM
Not at all; simply change the anchor tag to something like:
<a href="javascript:void(0);" onclick="doStuff();return false;">Menu Item 1</a>
Better still, if you have anything better and appropriate to link to, change javascript:void(0); to an URI. This won't affect JavaScript browsers, only non-JS ones.

thecraigmcrae
07-26-2005, 02:09 PM
ok, new problem. if i select option one, that corresponding div appears, but if i meant to click option two and go back to select it again, now they're both open. what would you do to ensure that when one opens the other is closed/hidden?

JavaRulez
09-10-2005, 09:43 AM
I'm trying to get my menu to show a div box depending on which option is selected. I had two "hidden" div boxes with text in them, and when i select option 1 i would like that corresponding div to appear, but if i select another i would like to make sure all other divs are hidden and show the correct box. Any ideas?

I actually made that specific scenario to work.
If you want I will email you the code I've used.
It is pretty interesting, it took me awhile. The only thing I am having issues is that the text will apear properly but if I select the text it will select all DIV Items together.
send me an email to seriy1@gmail.com I will respond with a sample code.