Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2003
    Location
    Ohio
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    linking items in a list box to a webpage (with frames)

    Here's the little problem I have facing me...

    I have a webpage that will have frames in it... There will be a top and left frame with a main area for placing html files. However the top and left frames will be static while the main area will change.

    If I place a drop down list box on the left frame and it looks something like this:

    Code:
    <form name="dropdownlist1" method="post" action="">
      <select name="select" size="1">
        <option>Select an Event</option>
        <option>100M Dash (P)</option>
        <option>100M Dash (F)</option>
        <option>200m Dash (P)</option>
      </select>
    </form>
    How do I get each event to relate to a specific html file and show that html file that has been selected by the user to show up in the main page area? I've been told I should do this using javascript however I haven't been able to find exactly what I'm looking for. I did find an example of it here but I've tried looking at the source code and I was just confused...

    Thanks for your help!

    blkshirt

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    <select name="select" size="1" onchange="if (this.selectedIndex>0) window.open(this.options[this.selectedIndex].value,'nameOfTargetFrame')">
    <option>Select an Event</option>
    <option value="p100.htm">100M Dash (P)</option>
    <option value="f100.htm">100M Dash (F)</option>
    <option value="p200.htm">200m Dash (P)</option>
    </select>

    or:

    <select name="select" size="1" onchange="if (this.selectedIndex>0) top.frames['nameOfTargetFrame'].location.href=this.options[this.selectedIndex].value">
    ...

    But I prefer the 1st solution.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    Dec 2003
    Location
    Ohio
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by glenngv
    <select name="select" size="1" onchange="if (this.selectedIndex>0) window.open(this.options[this.selectedIndex].value,'nameOfTargetFrame')">
    <option>Select an Event</option>
    <option value="p100.htm">100M Dash (P)</option>
    <option value="f100.htm">100M Dash (F)</option>
    <option value="p200.htm">200m Dash (P)</option>
    </select>

    or:

    <select name="select" size="1" onchange="if (this.selectedIndex>0) top.frames['nameOfTargetFrame'].location.href=this.options[this.selectedIndex].value">
    ...

    But I prefer the 1st solution.
    Is
    window.open(this.options[this.selectedIndex].value,

    logical code? Or do I need to modify it???

    If my target frame is "main.html" the code would look like this?

    Code:
    <select name="select" size="1" onchange="if(this.selectedIndex>0) window.open(this.options[this.selectedIndex].value,'main.html')">
        <option>Select an Event</option>
        <option value="p100.htm">100M Dash (P)</option>
        <option value="f100.htm">100M Dash (F)</option>
        <option value="p200.htm">200m Dash (P)</option>
      </select>

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You only need to modify the 2nd parameter in the window.open().
    You should put the name of the target frame not the html page in it. Look at your frameset page where you define your three frames: top, left and main. If you name the main frame as mainFrame, the code would be:

    Code:
    <select name="select" size="1" onchange="if(this.selectedIndex>0) window.open(this.options[this.selectedIndex].value,'mainFrame')">
    <option>Select an Event</option>
        <option value="p100.htm">100M Dash (P)</option>
        <option value="f100.htm">100M Dash (F)</option>
        <option value="p200.htm">200m Dash (P)</option>
      </select>
    Of course, you also need to change the corresponding html page for each option
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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