SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple Java Script Help Please

    Hi,

    I'm using this bit of Javascript for a jump menu:

    onChange="top.window.location.href = '/'+this.options[this.selectedIndex].value+''">

    However (I'm terrible at JS by the way) I cant get it to do what I what as I require it to jump a combination of full URLs like http://blah.com, and relative urls like /forum.html . How can I get this to work?

    What I really need is it to jump to exactly what is written in the value tags like this:
    <option value="humour/">Humour</option>
    <option value="http://www.link.com">link</option>


    Any ideas???

    cheers
    Last edited by ChilliBoy; Aug 16, 2001 at 11:44.

  2. #2
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    <select name="jump" onchange="window.location.href=this.form.jump.options[this.form.jump.selectedIndex].value;" size="1">
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Jeremy,

    Just a couple of QU's

    1/. What the size="1"> for ?

    2/. Will that JS bust out of a frame set ? or do I need to add 'top' in somewhere ?

    Thanks for the prompt reply.

  4. #4
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    I worked out you need to add 'top' to get it to bust out of frames.

    I now need to know if there is any way possibe that I can produce a drop form which has different 'targets' depending upon the option selected.

    I tried adding tags like target="_blank" inside the individual option tags but it didn't seem to have any effect - do you have any suggestions on how this is possible.

    Thanks in advance.

  5. #5
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yeah... hangon...

    Okay, size="1" is so that it isn't a scrolling menu.

    <select name="jump" onchange="doJump(this.form.jump.options[this.form.jump.selectedIndex].value,'top')" size="1">

    Then you'd have:

    Code:
    <script language="javascript" type="text/js">
    <!--
    
    function doJump(loc,target)
    {
    	target.location.href=loc;
    }
    
    // -->
    </script>
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  6. #6
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help.

    Do then just stick the targets within the option tags for it to work ?

    Sorry - I'm ok a php but a real dumb *** at JS - like you cant tell

  7. #7
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <select name="jump" onchange="doJump(this.form.jump.options[this.form.jump.selectedIndex].value,'top')" size="1">

    Then you'd have:



    code:--------------------------------------------------------------------------------
    <script language="javascript" type="text/js">
    <!--

    function doJump(loc,target)
    {
    target.location.href=loc;
    }

    // -->
    </script>
    --------------------------------------------------------------------------------


    Hummm I tried the above script but it doesn't work for some reason - also show JS error in the browser - any ideas?

    Thanks


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
  •