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 7 of 7
  1. #1
    New Coder
    Join Date
    May 2003
    Location
    New Jersey
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamic Hyperlink

    I have a form with a drop down list box containing years, (ex. 2003, 2004, etc.) I have a hyperlink that needs to pass the year that the user clicked from the drop down box. How can I do this?

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Code:
    <script>
      function GotoPage(theUrl){
        var sel = document.theForm.theDropDown;
        var txt = sel.options[sel.selectedIndex].text;
        window.location.href= theUrl + "?theYear=" + txt;
      } 
    </script>

  • #3
    New Coder
    Join Date
    May 2003
    Location
    New Jersey
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks A1ien51, but how do I call this function? Is it done in the href statement?

  • #4
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    easiest way

    href="javascript:GotoPage('theurl.htm')"

  • #5
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    <a href="choseyearmanually.html" onclick="GotoPage('blah');return false;">
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #6
    New Coder
    Join Date
    May 2003
    Location
    New Jersey
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks-a-million!!!

  • #7
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Just make sure you actually make a "chooseyearmanually.html" in case the user doesn't have javascript enabled.
    OracleGuy


  •  

    Posting Permissions

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