Dropdown List problem

Hi All.

This is the first time I have used JavaScript, and Im stuck :)

I have two frames.  The top frame (called "top") has a drop down list box in it and a button.  Within this list is all the forms on my web page.  When I click the select button, the newly selected document is loaded in the whole window, not in the bottom frame (called "main").  

Im sure there is an easy way of doing this, but being new and all...  Enough of the excuses, right!

Please help :)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

well, since you haven't posted any of your code, I can't tell you exactly what's wrong, but there are twio things that seem obvious:

1) Don't call any of your frames "top" --- "top" is "kind of a reserved" word and refers to the highest-level-frame in the window (i.e. the whole window) --> that's probably (99% *g*) the reason your document is loaded in the whole window. Rename the frame to "topFrame" or to "navFrame" (navigation).

2) the command would/should be parent.main.location.href=whatever...

Let me know if that helps and post some code if it doesn't...
oh, btw: You said you were new - have you read the FAQ? You are not supposed to reject an answer just because it doesn't work 100% - just post another comment and I'll answer 'til it works (really shouldn't be too long :-). You can reject the answer if you feel that the "current expert" (i.e. me in this case :-) won't be able to help you solve your problem...

Good luck!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Stuart_JohnsonAuthor Commented:
I'll try that when I get home tonight.  Thanks.

I have been using EE for over 18 months now, so I am familiar with the methods of use.  Its just the first time I have used the Java area.

Stuart_JohnsonAuthor Commented:

Im still not having any luck with it.  Here is my original code.  Is that any help?

function testSelect(form){
        myArray=new Array(numEntries);


<form method="get" name="choice" target="main">
    <p align="right"><select name="list" size="1">
        <option>Main Page</option>
        <option>A brief overview</option>
        <option>Low resolution screen shots</option>
        <option>High resolution screen shots</option>
        <option>Walk Through - Virtual Database</option>
        <option>Patches and Pre-Releases</option>
        <option>Content Updates</option>
        <option>Wanted! Who Stuff!</option>
        <option>Suggestions and Comments</option>
        <option>Links to other Sites</option>
    </select> <input type="button" name="seek" value="Go!"

Thanks for your help,

The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!


I took your code and found that it CAN WORK!  Here's the simple solution:

In your framesetter document, probably index.html (but maybe not) your code should look something like this:

<frameset  framespacing="0" border="0" rows="50,*">
      <frame src="menu.htm" name="topmenu" scrolling="no">
      <frame src="main.htm" name="main" scrolling="auto">
(NOTE the names of the frames I've set)

THEN, in your menu.html (holding the JavaScript) the ONLY change you need to make to your code to make it work is:


See, in Javascript, you have to go BACKWARDS to the PARENT window FIRST, then call the name of the frame that you assigned in the framesetter document.  You cannot call the name of the frame directly from the CHILD frame standpoint.

Holger is right about the word "top", but it is usually referred with an underscore "_top"... but in any case you should avoid words that are even similar to reserved words, just to be safe.

If you are satisfied with this comment, lemme know and perhaps it will be changed to an answer!

Good luck!
Stuart, something else kinda cool you could add to the code would be to eliminate the "GO!" button and have the pages load as soon as someone makes a selection from the drop-down list... it's simple, and here's the line to modify:

<select name="list" size="1" onchange="testSelect(this.form)">
First a quick note to rodm:
Since you're new I'll give you the benefit of doubt... if you had been at Experts-Exchange longer, I might be a little angry because what you're doing is effectively "stealing" this question (or at least trying it). Your saying that your comment might be changed into an answer means that my answer would have to be rejected. WHY?? You really don't say anything new! Of course you could be a little more specific because you could see the code, but the whole answer is in my two remarks!
* Also, you are NOT correct about "top". In HTML code, it is referred to as "_TOP", but in JavaScript, the variable is "top".
* Your second idea is good and I wanted to propose that as well, but you can't get rid of the "GO" button, because some browsers (e.g. IE3) don't support onchange for a Select-object which would effectively trap the user on the page.

Now for Stuart:
Being a good expert, I'll tell you much more than you asked for *g*
Most important thing first: Where is the problem? Look at my first answer and change "top.location.href=(myArray[selection]);" to "parent.main.location.href=(myArray[selection])". That should make your code work, but you should nevertheless rename your "top frame" to something other than "top", because "top" refers to the window and always causes trouble (but whom am I telling this? *g*)
Now some "added value": some remarks about your code and a much nicer solution:
1) numEntries=8;
   myArray=new Array(numEntries);
That's not very efficient code. The second and third line do the same thing! And it's a thing you don't need to do at all...
All you need is myArray=new Array();
2) Also, take another look at your code: You create an array of 8 elements and then assign 11 elements to it!!
3) It's "cleaner" to pass the select-object instead of the form. The point of using functions is to make them flexible and they are not flexible if they always look for an element called "list".
4) Both "method=get" and "target=main" are useless, because the form is never actually submitted!
5) Those were just small remarks, here's a big one:
Each element in a select-object can have a "value" field!!
A very nice way of using this feature looks like this:
It's not only shorter, but also much easier to read and maintain (imagine inserting another item or rearranging them!)

     function testSelect(sel){
       alert("Going to\n"+nURL);      


     <form method="get" name="choice" target="main" > 
         <p align="right"><select name="list" size="1" onchange="testSelect(this)">
             <option value="main.htm">Main Page</option>
             <option value="brief.htm">A brief overview</option>
             <option value="screen_lo.htm">Low resolution screen shots</option>
             <option value="screen_hi.htm">High resolution screen shots</option>
             <option value="wtintro.htm">Walk Through - Virtual Database</option>
             <option value="patches.htm">Patches and Pre-Releases</option>
             <option value="content.htm">Content Updates</option>
             <option value="utilities.htm">Utilities</option>
             <option value="wanted.htm">Wanted! Who Stuff!</option>
             <option value="suggestions.htm">Suggestions and Comments</option>
             <option value="links.htm">Links to other Sites</option>
         </select> <input type="button" name="seek" value="Go!"

Good luck and have fun!
Lastly, a quick note to Holger:
I wasn't trying to "steal" a question, I was merely trying to help a person out — you should refrain from being so emotional.
I'm not in this for points; I'm in this to help. Please, continue your work with Stuart.  I'll leave this one alone.

Sorry, Stuart.
No problem at all... of course I wouldn't ask anybody not to post comments that might be helpful.
The only sentence that annoyed me was "...maybe this comment will be changed into an answer", because it really does imply rejecting my answer (which does answer the question).

I'm not in this for the points either and normally post much more than I'd have to to get the points. (what are points good for anyway?). However, if I anwer a question and don't like
a) the answer being rejected although it is correct and complete
b) If somebody adds two lines to one of my comments and posts it as an answer...

well.... take it easy :-)))
Stuart_JohnsonAuthor Commented:
HAY FELLAS!  Cool it down a bit.  I was after help, not a damn shooting match.  

Rodm:  Thank you for posting your comments.  I appreciate help, the more the better -  believe me, I need it :).  

Holger.  Again, I will try out your suggested answer.  I will get back too you in a couple of hours.  

Just so you know, I will NOT give points out to other people if someone has already posted a suggested answer.  I will reopen the question though if the answer does not work.  If someone then answered the question in a comment, I would ask them to post it as an answer.

I dont think rodm was trying to "steal" the question from you.  He was mearly opinionating constructive advise.  I do it quite often in the VB, Pascal, Delphi and Windows areas with no intention what so ever of taking someones glory from them.

Stuart_JohnsonAuthor Commented:
Thanks very much to both of you.  I now have it working :)

Stay tuned for more questions and annoyances.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.