Access listbox Options using Multiple Frames
I am creating a recipe cookbook program. On the main page, I have a top frame (named "nav") and bottom frame (named "recipe_layout"). There is a listbox in the BOTTOM frame containing the recipe names, and a "View Recipe" button in the TOP frame. The user would select a recipe and then click the button to view the recipe in the bottom frame. I believe that I need to insert the code to make this work with the button (?), and I think my problem is that I'm not accessing the bottom frame correctly:
CURRENT CODE FOR LISTBOX IN BOTTOM FRAME
<form name="recipe_form" style="margin-top:30">
<select name="name_dropdown" multiple size="2">
<option selected="selected">Search byName</option>
<option value="applepie.html">Apple Pie</option>
CURRENT CODE FOR BUTTON IN TOP FRAME
<input type="button" value="View Recipe" onclick="parent.recipe_layout.location.href='recipe_form.name_dropdown.options[selectedIndex].value'">
Thank you so much in advance!!
How come your listbox and the corresponding 'go' button are in different frames, or did I miss something? Shouldn't they sit next to each other?
Wow! I am extremely appreciative - I struggled with this for hours yesterday.... I'm really trying to learn this, so could you explain to me why you don't need .options[selectedIndex]? Also, I can understand why I have to repeat "recipe_layout" in the location.href, but why repeat "parent", since I thought that would point to the top frame, not the bottom frame?
Mitya, what I really have is a nav in the top frame, with other options besides viewing the recipe, such as adding the recipe to a favorites list and printing it.
Fang solved my problem, but thanks so much!
That would have been:
which is the same as
When referencing the text of an option you can only use
parent refers to the frameset document
Very interesting.... Fang, thank you so much.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread