[thelist] simple Javascript help

Joshua Olson joshua at waetech.com
Fri Nov 1 08:12:01 CST 2002


----- Original Message -----
From: "Drew Shiel" <ashiel at sportsinteraction.com>
Sent: Friday, November 01, 2002 8:57 AM


> I will freely admit that I'm no good at all at Javascript. And all the
> scripts I can find on the web do something similar, but not the same.
>
> 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".

Drew,

My experience has been that there is no really easy way to make for elements
disappear and reappear across all browser platforms.  If you are targetting
one browser in particular, then this task will be simplified somewhat.

> function CheckBanner(Option_List){
>   var Checkee = Option_List.options[Options_List.selectedIndex].value;
>   if (Checkee == "Banner")
>     document.write ("<select name=size>
>       <option>Banner Size</option>
>       <option>60 x 60</option>
>       <option>120 x 60</option>
>       <option>180 x 60</option>
>       </select>");
> }

The principal error in your approach is that you are attempting to change
the layout of the page using document.write().  document.write adds text to
the end out output stream.  If document.write is called from within a
user-activated function, it'll do one of two things:

1.  Clear the page and write out to a new page the output you specify.
2.  Add the output to the end of the current page.

It all depends on whether the document is open for editing or not and is
probably somewhat browser specific.

What you probably want to do it hide and expose elements using css.  Each
element on the page has a property called style.display.  Setting that
property to "none", "block", or "inline" will affect how it's displayed.
Play around with that and see if you can get the results you need.

-joshua





More information about the thelist mailing list