There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios boot browser bsod computer cpu crash css dell desktop driver dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware help please hijackthis hjt install internet internet explorer itunes javascript keyboard lan laptop malware monitor network networking openoffice outlook outlook 2003 outlook express password popups problem router screen seo slow sound sp3 spyware startup trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless word
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Jump Menu And IFrames


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Cravepain's Avatar
Senior Member with 106 posts.
 
Join Date: May 2007
Experience: Beginner
07-May-2008, 09:39 PM #1
Jump Menu And IFrames
Hello,

I have made a thread on here before regarding my website, and I got plenty of help. Now, I have another issue. I have tried to solve this one myself, but it doesn't seem to be working out. I'm sorry guys - I am trying.

I have a Jump Menu created which I want to open up in a certain IFrame I have. What it is doing now is simply taking over the whole page.

Here is the code I have. I would like for it to open up in a IFrame named content-frame:

<select name="jumpMenu" id="jumpMenu" onChange="MM_jumpMenu('parent',this,0)">
<option value="about.html">About Me</option>
<option value="chemical.html">Chemicals</option>
<option value="comments.html">Comments</option>
<option value="coupons.html">Coupons</option>
<option value="directions.html">Directions</option>
<option value="hair.html">Hair</option>
<option value="hairremoval.html">Hair Removal</option>
<option value="main.html">Home</option>
<option value="links.html">Links</option>
<option value="products.html">Products</option>
<option value="schedule.html">Schedule</option>
<option value="services.html">Services</option>
</select>


Thank you so much, again, guys. I am sorry for being a pest.
Jayec's Avatar
Junior Member with 9 posts.
 
Join Date: May 2008
07-May-2008, 11:12 PM #2
Try replacing line 1 with:

<select name="jumpMenu" id="jumpMenu" onChange="MM_jumpMenu('content-frame',this,0)">
Cravepain's Avatar
Senior Member with 106 posts.
 
Join Date: May 2007
Experience: Beginner
08-May-2008, 12:43 AM #3
That didn't work. It stopped loading the pages all together.
Jayec's Avatar
Junior Member with 9 posts.
 
Join Date: May 2008
08-May-2008, 01:29 AM #4
Ok. I'm not too familiar with Java
Hopefully someone else will be able to tell you how to modify the scipt used in your site (below).

Code:
<script>
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
</script>
Code:
<select name="jumpMenu" id="jumpMenu" onChange="MM_jumpMenu('parent',this,0)">
<option value="about.html">About Me</option>
<option value="chemical.html">Chemicals</option>
<option value="comments.html">Comments</option>
<option value="coupons.html">Coupons</option>
<option value="directions.html">Directions</option>
<option value="hair.html">Hair</option>
<option value="hairremoval.html">Hair Removal</option>
<option value="main.html">Home</option>
<option value="links.html">Links</option>
<option value="products.html">Products</option>
<option value="schedule.html">Schedule</option>
<option value="services.html">Services</option>
</select>
Cravepain's Avatar
Senior Member with 106 posts.
 
Join Date: May 2007
Experience: Beginner
08-May-2008, 01:37 AM #5
It's alright. Thank you for trying. It was very nice of you.
tomdkat's Avatar
Computer Specs
Distinguished Member with 2,968 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
08-May-2008, 02:02 PM #6
First, you've got to understand the tools you use so you can use them effectively.

The JavaScript you're using isn't intended to work with iframes. So, some new JavaScript is needed. First, make this change to your iframe:

Code:
<iframe src="main.html" style="margin-top: 0px; padding-top: 0px;" id="content-frame" name="content-frame" frameborder="0" height="100%" scrolling="auto" width="100%">
Note the addition of the id attribute. We will need this to retrieve the iframe element later on.

Now, add a new JavaScript function for your menu:

Code:
function processMenuChoice(menu) {
targetPage=menu.options[menu.selectedIndex].value;
document.getElementById('content-frame').src=targetPage;
}
Thisis the function that will load the page selected from the menu into the iframe. First, it will get the target page from the menu selection. Then, it will fetch the iframe and set the src attribute to the location from the menu selection. At least, that's the idea.

Then, change your select menu to this:
Code:
<select name="jumpMenu" id="jumpMenu" onChange="processMenuChoice(this)">
This will invoke the new JavaScript function instead of the "MM_jumpMenu()" function.

See what happens. I haven't actually tried the code above so it might need some tweaking.

Peace...
Reply

Tags
iframe, javascript


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:33 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.