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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hyperlink passing parameters when clicked

    I have two links as shown below. The destination page needs to know which link was clicked in order the render the page accordingly. How could I accomplish that? Can I get some help.

    <a href="javascript:func1()" >Historical data 1</a>
    <a href="javascript:func2()" >Present data 2</a>

    Should I put constant variable in javascript

    I tried
    <a href="javascript:func1()" id = "1">Historical data 1</a>
    <a href="javascript:func2()" id = "2">Present data 2</a>
    but how could i write code in destination page to retrieve these values.

    Thanks for the help !!!

  • #2
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,335
    Thanks
    5
    Thanked 363 Times in 360 Posts
    What the code in your functions? Ideally you'd use server side language to pass url variables to the processing page.

    <a href="somePage.cfm?somevariable=somevalue">Historical Data 1</a>
    Teed

  • #3
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the Reply... But I have to use JavaScript functions in order to go the right destination page. Can I add something in JavaScript or in href to pass another constant variable. I can post my JavaScript code if necessary.

    function func1(){
    var val = document.form.Year.value;
    var si = document.form.Year.selectedIndex;
    var textval = document.form.Year.options[si].text;
    if(textval > 2010)
    {
    document.form.action ="Page1.asp";
    document.form.method = "post";
    document.form.submit();
    }
    else if (textval < 2011)
    {
    document.form.action ="page2.asp";
    document.form.method = "post";
    document.form.submit();
    }
    }

    Similarly func2() is same except else part is directed to page3.asp
    Last edited by pinky14; 02-17-2012 at 05:13 PM.

  • #4
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,335
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Quote Originally Posted by pinky14 View Post
    Thanks for the Reply... But I have to use JavaScript functions in order to go the right destination page. Can I add something in JavaScript or in href to pass another constant variable. I can post my JavaScript code if necessary.
    Well no js isn't neccessary to "go to the right page". Is this a homework assignment?

    And to note, what happens if a user disables js? then your links dont work at all.

    But yes you can post your functions as I mentioned earlier, even thought I guess this woule be a js issue and should probably be in the js forum.

    When posting code, use the # button then paste your code between the code tags.
    Teed


  •  

    Posting Permissions

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