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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2009
    Posts
    204
    Thanks
    29
    Thanked 0 Times in 0 Posts

    Drop down menu Problem Help!

    Why does this not send page to the menu frame "menu"
    at the moment it sends it to new window.

    Help Please

    Code:
    <html>
    
    <head>
      <title>Hello!</title>
      <script type="text/javascript">
    
    
    //1) CUSTOMIZE TEXT DESCRIPTIONS FOR LINKS ABOVE
    var thetext1=new Array()
    thetext1[0]="Select Year"
    thetext1[1]="All Films"
    thetext1[2]="2007 Films"
    thetext1[3]="2008 Films."
    thetext1[4]="2009 Films"
    
    /// You may define additional text arrays if you have multiple drop downs:
    var thetext2=new Array()
    thetext2[0]="All Years."
    thetext2[1]="2007."
    thetext2[2]="2008."
    thetext2[3]="2009."
    
    // Now, see 2) below for final customization step
    
    function displaydesc(which, descriptionarray, container){
    if (document.getElementById)
    document.getElementById(container).innerHTML=descriptionarray[which.selectedIndex]
    }
    
    function jumptolink(what){
    var selectedopt=what.options[what.selectedIndex]
    if (document.getElementById && selectedopt.getAttribute("target")=="menu")
    window.open(selectedopt.value)
    else
    window.location=selectedopt.value
    }
    
    //2) Call function displaydesc() for each drop down menu you have on the page
    //   This function displays the initial description for the selected menu item
    //   displaydesc(name of select menu, name of corresponding text array, ID of SPAN container tag):
    //   Important: Remove the calls not in use (ie: 2nd line below if there's only 1 menu on your page)
    
    displaydesc(document.form1.select1, thetext1, 'textcontainer1')
    displaydesc(document.form2.select2, thetext2, 'textcontainer2')
    
    </script>
    
    
    </head>
    
    <body>
    <form name="form1">
    <select name="select1" size="1" style="background-color:#FFFFD7" onChange="displaydesc(document.form1.select1, thetext1, 'textcontainer1')">
    <option selected value="">Select Year</option>
    <option value="menu.php" target="menu">All Years </option>
    <option value="2007.php" target="menu">2007</option>
    <option value="2008.php" target="menu">2008</option>
    <option value="2009.php" target="menu">2009</option>
    </select>
     <input type="button" value="Go"
    onClick="jumptolink(document.form1.select1)"><br>
    <span id="textcontainer1" align="left" style="font:italic 13px Arial">
    </span>
    </form>
    
    </body>
    
    </html>

  • #2
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    hi,

    if you comment out ur code like this
    Code:
    function jumptolink(what){
    var selectedopt=what.options[what.selectedIndex]
    //if (document.getElementById && selectedopt.getAttribute("target")=="menu")
    //window.open(selectedopt.value)
    //else
    window.location=selectedopt.value
    }
    it forces the code to use the window.location. So it wud appear that when ever u run ur code it is using
    Code:
    window.open(selectedopt.value);
    instead of
    Code:
    window.location=selectedopt.value;


  •  

    Posting Permissions

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