Web Analytics Made Easy -
StatCounter drop down box help - CodingForum

Announcement

Collapse
No announcement yet.

drop down box help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • drop down box help

    on my site (which is currently down so i cant show u) i have drop down boxes, and i want to have a link in them that opens in a new window

    hope that makes sense, i have a few links, and only 1 i want to open in a new window, i know about the target+_blank, but that dont work in a drop-down box

    any help pls?

    thanks

  • #2
    Hi

    say the set is like this or so:

    <select>
    <option value="http://www.foo.com"> site 1 </option>
    <option value="http://www.foo2.com"> site 2 </option>
    </select>

    all you have to do is this:

    <select onChange="var myurl=this.options[this.selectedIndex].value; if(myurl)window.open(myurl,'x','');">
    <option value="http://www.foo.com"> site 1 </option>
    <option value="http://www.foo2.com"> site 2 </option>
    </select>

    that is:
    onChange="var myurl=this.options[this.selectedIndex].value; if(myurl)window.open(myurl,'x','');">

    and each otpion must carry a value="some url".
    -------

    If you want to open only ONE certain website, you can change to:
    onChange="var myurl=this.options[this.selectedIndex].value; if(myurl=='http://www.MYSPECIFICSITE.com')window.open(myurl,'x','');">

    Be careful with the apex. Where you see ....open(myurl,'x','') note they are all single apex, while the whole onChange is sourrounded by a double apex set.
    I hope this was what you meant, ciao
    TrueLies
    New to the CF scene
    Last edited by TrueLies; Jun 28, 2002, 01:39 AM.
    Alberto http://www.unitedscripters.com/

    Comment


    • #3
      that oes work, and yet it doesnt, see the problem is i already have that code in because rthe drop down controls frames, so when i try and put the new code in as well it puts the site one" next to the drop down, not insode

      weird, here is the exact code

      <form name="form2">
      <p align="center" style="margin-top: 0; margin-bottom: 0">
      <select name="Help" onChange="MM_jumpMenu('parent.frames[\'main\']',this,0)">
      <option selected value="gamelist_start.shtml">Choose One</option>
      <option value="RequestContact.shtml">Contact</option>
      <option value="FAQ.shtml">Sprite FAQ</option>
      <select onChange="var myurl=this.options[this.selectedIndex].value; if(myurl)window.open(myurl,'','');">
      <option value="http://www.cnn.com">site 1</option>
      </select></p>
      </form>

      Comment


      • #4
        function goToIt(theoptionlist) {

        var re = /http/;

        if ( re.test(theoptionlist.options[theoptionlist.options.selectedIndex].value)) {
        window.open(theoptionslist.options[theoptionslist.options.selectedIndex].value,"_blank");
        } else {
        MM_jumpMenu('parent.frames[\'main\']',theoptionlist,0);
        }
        }

        then change your onChange to
        <select name="Help" onChange="goToIt(this);">
        tamienne
        New to the CF scene
        Last edited by tamienne; Jun 28, 2002, 05:07 PM.

        Comment


        • #5
          didnt work

          maybe im doing it wrong or something, BTW the site is now working if u wanna take a look http://www.emusanet.com/gifgoodness/frames.shtml


          could you possibly just post the exact code start to finish

          heres the original

          <select name="Miscellaneous" onChange="MM_jumpMenu('parent.frames[\'main\']',this,0)" size="1">
          <option selected value="gamelist_start.shtml">Choose One</option>
          <option value="Links.shtml">Links</option>
          <option value="http://www.emusanet.com/forums">EMUSA Forums</option>
          <option value="staff.shtml">Staff</option>
          <option value="Submission.shtml">Submissions</option>
          <option value="Submitters.shtml">Submitters</option>
          <option value="Poll.shtml">The Weekly Poll</option>
          </select>


          this one- <option value="http://www.emusanet.com/forums">EMUSA Forums</option> - i want to popup in a new window

          thanks

          Comment


          • #6
            u know perhaps this will be easier, how about instead of popup in a new window, how about link out the frames,


            basically i have pages i want in the drop down box that i dont want in the frames

            Comment

            Working...
            X