# Jump Menu And IFrames



## Cravepain (May 13, 2007)

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*:

About Me
Chemicals
Comments
Coupons
Directions
Hair
Hair Removal
Home
Links
Products
Schedule
Services

Thank you so much, again, guys. I am sorry for being a pest.


----------



## Jayec (May 6, 2008)

Try replacing line 1 with:


----------



## Cravepain (May 13, 2007)

That didn't work. It stopped loading the pages all together.


----------



## Jayec (May 6, 2008)

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).


```
<script>
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
</script>
```


```
<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 (May 13, 2007)

It's alright. Thank you for trying.  It was very nice of you.


----------



## tomdkat (May 6, 2006)

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:


```
<iframe src="main.html" style="margin-top: 0px; padding-top: 0px;" [b]id="content-frame"[/b] 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:


```
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:

```
<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...


----------

