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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    submit to hyperlinks in a dropdown list

    I am a JS beginner. I have a dropdown menu in Cognos Report Studio that contains values that are hyperlinks to other reports. I need the JS code to perform a submit on the "Go" button. Below is an example of the code so far:


    <form name="SAMPLE">

    <select style="font-size:12px;color:#006699;font-family:verdana;background-color:#ffffff;" name="menu">
    <option value="http://Hyperlink1>Value 1</option>
    <option value="http://Hyperlink2>Value 2</option>
    <option value="http://cnn.com">CNN News</option>
    </select>

    <input style="font-size:12px;color:#ffffff;font-family:verdana;background-color:#006699;" type="button" onClick="window.open(document.SAMPLE.menu.options document.SAMPLE .menu.selectedIndex].value);" value="GO">

    </form>


    I probably need to clean up the onClick event with the correct JS.

    Any ideas?

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    onClick="window.open(this.form.menu.options[this.form.menu.selectedIndex].value);"

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks.

    I changed the code to read like this and it work too:

    <form name="Sample">
    <select name="menu"
    OnChange="location.href= Sample.menu.options[selectedIndex].value">
    <option selected>Please Select...
    <option value="Hyper1">value 1</option>
    <option value="Hyper2">value207</option>
    </select>
    </form>

    Do you know how to open it up in a seperate window???

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Yes, use the window.open instead of location.href

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #5
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks again!


  •  

    Posting Permissions

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