Click to See Complete Forum and Search --> : Frames navigation using onchange()


muschman
04-18-2003, 08:53 PM
I need a littel bit of help, anyone who can help me I would greatly appreciate it. Here is my problem: I am working on a site that is in frames, and one of the buttons opens up a new window with two frames also. The lower frame has a form that you can select different dancers and I want their bios to pop up in the top frame of the new window. Can anyone help me do this. If you are confused with my description, the webpage can currently be found at http://www.muschman.com/Paul/Frames.html click on dancers for the new window!

DrDaMour
04-19-2003, 01:22 AM
you're very close

<select onchange="parent.frames[0].location='D1.html' ">
<option selected value=none >&nbsp;Choose a dancer here:&nbsp;</option>
<option value="parent.frames[0].location='D1.html' " >Jeff</option>
<option value="parent.frames[0].location='D2.html' " TARGET="New">Dick</option>

first options don't have targets
second, the option just has a value that you can use, not somethign to be done (no = assignment operator)

so far it should look like...
<select onchange="parent.frames[0].location='D1.html' ">
<option selected value="DTop.html">&nbsp;Choose a dancer here:&nbsp;</option>
<option value="D1.html">Jeff</option>
<option value="D2.html">Dick</option>

finally the onchange is where you use the = operator to make somethign happen, you are probably targeting the rightframe by doing frames[0] but it's better to do frames.framename
but i leave that to you.
so the onchange event should look like:

onchange="parent.frames[0].location.href= this.options[this.selectedIndex].value"

that should work

now one other thing, where are the girly girl dancers?

Jona
04-19-2003, 07:12 AM
I don't know about Netscape, but in Internet Explorer, I can use "this.options.selectedIndex" and it works fine. DrDaMour, do you know why this is? Is it just a shortcut or is there a reason for its existence otherwise? In all situations, both have worked for me, but I was just curious. :)

DrDaMour
04-19-2003, 10:24 AM
yeah the way arrays are handeled is really pretty cool

it's like this


array[index] = array.index

so:

options[this.seclectedIndex]=options.selectedIndex


now you may be questioning the this. well when it's the index of the array, it's looking for an integer and starting nowhere, so you have to give it somewhere to start, however when you use the . operator, it's still in the doamin of options which has the member selectedIndex.

I'm not really sure what is more correct, but i'm a C coder by nature, so i live and die by the [] operator :)

Jona
04-19-2003, 12:34 PM
I understand the way arrays work and the "this." I was just wondering if there was any difference, and you have told me that there isn't (in short). It's just like document.all['id'] = document.all.id, and document.images[0] and document.images.0.

I figured that out, because some error say, "document.images.0 is null or not an object." But that actual line of code says "document.images[0]."

Thanks, though. :)