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

    changing link based on variable

    I need to add a value to a link, based on the value of a variable. (This is because my site is not allowed to use cookies.) I am passing this variable from one page to another by means of a function:
    <script language="JavaScript"><!--
    //this function will take a passed URL and add the ?db= segment.
    //Do NOT call this for pages going to the correct Basic/Advanced pages.
    function intercept(what) {
    what.href += '?db=' + db; //adds the correct db scenario (?db=...) to the end of the URL
    }
    //--></script>

    However, there are a few times where I need to add this to the URL itself--instead of basic/basic.htm I want the user to go to basic/basic_"valueofdb".htm.

    I can't figure out how to do this! I can write code that will put the correct path into a variable, but cannot return this variable to the link.

    ANy advice?

    N

  • #2
    New Coder
    Join Date
    Dec 2002
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <script language="JavaScript"><!--
    //this function will take a passed URL and add the ?db= segment.
    //Do NOT call this for pages going to the correct Basic/Advanced pages.
    function intercept(what,addToUrl)
    {
    // Check a boolean var if you want to add the db var to the href
    if (addToUrl)
    {
    var vArr = split(what.href,"."); // Splitting up http://somthing.com/somthing.htm into an array.
    var vFirstHalf = vArr(0) + "" + vArr(1) + "_" + db; // assuming there is a .com or something.
    var vSecondHalf = vArr(2) ;
    what.href = vFirstHalf + vSecondHalf;
    }

    what.href += '?db=' + db; //adds the correct db scenario (?db=...) to the end of the URL
    }
    //--></script>
    Last edited by wyattwebb; 03-24-2003 at 06:11 PM.


  •  

    Posting Permissions

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