[thelist] simple Javascript help

Tom Dell'Aringa pixelmech at yahoo.com
Fri Nov 1 08:15:01 CST 2002

--- Drew Shiel <ashiel at sportsinteraction.com> wrote:

> What I need to happen is for the second drop-down (banner size) to
> appear
> when the option in the first dropdown (category) is "banner".
> Here's what I have: <snip>

Drew, not a big fan of document.write myself. What I would do is hide
the second select in a DIV that has display set to none, then show it
if they choose banner..see below:

<script language="JavaScript">

function CheckBanner(yourFirstSelect)
var chosen = (yourFirstSelect.selectedIndex);

	if(chosen == 2)
		 var otherSelect = document.getElementById('show');
		 otherSelect.style.display = "block";


<select name="type" OnChange="CheckBanner(this)" >
<option>Type of Promo Tool</option>
<option value="All">All</option>
<option value="Banner">Banner</option>
<option value="Text Link">Text Link</option>
<option value="Web Services">Web
<option value="Web Services">Content</option>
<div id="show" style="display: none;">
<select name="size" id="size">
<option>Banner Size</option>
<option>60 x 60</option>
<option>120 x 60</option>
<option>180 x 60</option>


The select object automatically sends you a variable you can use on
onChange, the selectedIndex, which is an array number of all the
options. Banner is 2. Since you are sending the object with 'this'
you can grab that easily using yourFirstSelect.selectedIndex.

If its 2 - the banner - the show the div.

Then you don't have to use write. If you need to degrade to older
browsers, you'll have to do a bit more work.



var me = tom.pixelmech.webDeveloper();

[Making A Commercial Case for Adopting Web Standards]

Do you Yahoo!?
HotJobs - Search new jobs daily now

More information about the thelist mailing list