SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    NL
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dropdownmenu which loads two frames

    currently I'm working on a dropdown box/menu. I know I can use the following code to make a normal dropdownmenu:
    Code:
    <SCRIPT LANGUAGE="JavaScript" type="text/javascript">
    <!-- Begin
    function leapto(form) {
    var myindex=form.dest.selectedIndex
    parent.frameB.location.href=(form.dest.options[myindex].value);
    // You can output to ANY frame using:  parent.[framename].location.href
    }
    // End -->
    </SCRIPT>
    and
    Code:
    <FORM NAME="myform">
            <SELECT NAME="dest" SIZE=1 onChange="leapto(this.form)">
    		<option selected>Select Year</option>
    		<option value="2003/2003.htm">2003</option>
    		<option value="2004/2004.htm">2004</option>
    		<option value="2005/2005.htm">2005</option>
    	</SELECT>
    </FORM>
    but now i want to make one which loads another page too. So when I choose "2003" it should load 2003.htm in frameB and 2003a.htm in frameC. (menu is in frameA) How can I do that?

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    first change
    <SELECT NAME="dest" SIZE=1 onChange="leapto(this.form)">
    to

    <SELECT NAME="dest" SIZE=1 onChange="leapto(this.options[this.selectedIndex].value)">

    then

    <option value="2003/2003.htm">2003</option>
    to

    <option value="firsturl.htm^secondurl.htm">2003</option>

    then

    function leapto(form) {
    var myindex=form.dest.selectedIndex
    parent.frameB.location.href=(form.dest.options[myindex].value);
    // You can output to ANY frame using: parent.[framename].location.href
    }

    to

    function leapto(url) {
    parent.frameB.location.href=url.split('^')[0];
    parent.frameC.location.href=url.split('^')[1];
    // You can output to ANY frame using: parent.[framename].location.href
    }


    or variations of

  3. #3
    SitePoint Member
    Join Date
    Jan 2005
    Location
    NL
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the quick reply
    I've tested the script now, but it doesn't really work. Maybe because I'm trying to load the pages from an iframe?
    I have a page which has three inline frames (iframes) on it.
    iframe1 is called 'hitlist', iframe2 is called 'rotw', iframe3 is called 'calender'
    iframe3 (calender) has the dropdown menu. When a user selects an option from that menu, it needs to load two pages:
    page1.htm into iframe1 (hitlist)
    and
    page2.htm into iframe2 (rotw)?

    I've tried renaming:
    parent.frameB.location.href=url.split('^')[0]; into parent.hitlist.location.href=url.split('^')[0];
    and
    parent.frameC.location.href=url.split('^')[1]; into parent.rotw.location.href=url.split('^')[1];
    but that gives me an error.
    the error says either parent.rotw.location or parent.hitlist.location doesn't exist or isn't an object.
    how can I fix this?

    edit:typo

  4. #4
    SitePoint Member
    Join Date
    Jan 2005
    Location
    NL
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    found the solution already.
    turned out I forgot an "=" in the name="hitlist" attribute of the iframe. fixed that, and it worked


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •