View Full Version : Show/Hide via dropdown menu?

04-01-2010, 04:29 AM
Can someone help me make a dropdown menu that will show and hide a div when a option is select.

Select: Type1, Type2 (drop-down menu)

If Type2 is selected show Works Form (DIV id=works)
If Type1 is selected show New Form (DIV id=new) make sure DIV id=works is hidden.

div id=new will always be shown, div id=works is the div that will be shown if its select with Type2

Thanks in advance.

04-01-2010, 09:12 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<style type="text/css">
.hide {

<script type="text/javascript">

function Cng(obj){
var opts=obj.options;
for (var z0=0;z0<opts.length;z0++){
if (document.getElementById(opts[z0].value)){


<select onchange="Cng(this);" >
<option value="" >Option 0</option>
<option value="works" >Option 1</option>
<option value="new" >Option 2</option>

<div id="works" class="hide" >WORKS</div>
<div id="new" class="hide" >NEW</div>