Click to See Complete Forum and Search --> : JS newbie needs a little help


ImageMage
08-07-2004, 05:45 PM
Hi all. I'm doing a small website for a friend of mine trying to revamp her website. I've got just about everything working except one thing.

I have a drop-down jump menu that needs to have TWO things happen when a use selects an item from it. I have two iframes in the html file, and upon selection, BOTH iframes' source file must change. I can get ONE of them to change easily, but not both when a user selects a product from the drop-down menu. I'm sure there's an easy way to do it - I've seen it on sites before, but I've been knocking myself on the head all day and can't get anything I've tried to work.

The test-sight, if anybody wants to see it, is available at:
http://www.imagemage.com/bb/fashion/fashion-slingpops.html

MANY thanks in advance to all; it is greatly appreciated. My last question of the evening is can somebody recommend an easily-understandable Javascript book for a designer? I know HTML well, and even some PHP, but Javascript has eluded me thus far. Again, MANY thanks - I hope to someday master this language...

Pittimann
08-08-2004, 03:32 AM
Hi!

There are many ways to achieve what you want. This is one of them:

Your function could look like this:

function MM_jumpMenu(targ,targ2,selObj,restore){
parent.frames[targ].location=selObj.options[selObj.selectedIndex].value.split('|')[0];
parent.frames[targ2].location=selObj.options[selObj.selectedIndex].value.split('|')[1];
if (restore) selObj.selectedIndex=0;
}

That would also avoid using the eval() function there, which really is unnecessary. Then your select:

<select name="swatchlist" onChange="MM_jumpMenu('swatch','buy',this,0)">
<option selected>Please Choose:</option>
<option value="iframes/SPAC-swatch.html|iframes/SPAC-buy.html">SPAC</option>
<option value="iframes/SPAE-swatch.html|iframes/SPAE-buy.html">SPAE</option>
</select>

Just use this pattern for more entries:
<option value="url_for_iframe_swatch|url_for_iframe_buy">SPAC</option>
both urls in one single string, separated by a "|" (without quotes).

Cheers - Pit

ImageMage
08-08-2004, 05:58 PM
Thank you VERY much - it worked perfectly! I really do plan on learning Javascript better by the end of this year, so I won't have to ask any more questions like this. Many thanks again!

Pittimann
08-09-2004, 12:16 AM
Hi!

Glad that it helped. You're welcome!

Regards - Pit