centenial Posted May 27, 2006 Share Posted May 27, 2006 Hi,I've been driving myself crazy the past couple hours and can't figure this out. Here is what I need to do:Have a select box like this:[code]<select name="dropdown"><option value="option1">option1</option><option value="option2">option2</option></select>[/code]Then when one of those options is selected, the appropriate div tag is displayed:[code]<div id="option1">Div 1 Text</div><div id="option2">Div 2 Text</div>[/code]This seems like it should be really simple to do, but I can't figure it out. Please help someone? Link to comment https://forums.phpfreaks.com/topic/10552-js-switch-content/ Share on other sites More sharing options...
nogray Posted May 30, 2006 Share Posted May 30, 2006 Try this[code]<script language="javascript"> function hide(){ document.getElementById('option1').style.display = "none"; document.getElementById('option2').style.display = "none"; } function show(wdiv){ hide(); document.getElementById(wdiv).style.display = ''; }</script><select name="dropdown" onChange="show(this.value);"><option value="option1">option1</option><option value="option2">option2</option></select><div id="option1" style="display:none;">Div 1 Text</div><div id="option2" style="display:none;">Div 2 Text</div>[/code]Make sure you include all the divs to the hide function, Link to comment https://forums.phpfreaks.com/topic/10552-js-switch-content/#findComment-40329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.