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

    passing variables in href tag

    What is the correct syntax for passing variables in a href tag when the href is outside of the javascript tags? I believe it is not recognizing the href because it is not reading the variables: boxid & projectname. Please advise.

    *******************************************************


    <script type="text/javascript" language="javascript">

    var linkURL = '';
    var boxid = '';
    var changeLinkURL = '';


    function getUrlVars()
    {
    var vars = [], boxid;
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
    vars[key] = value;
    });
    return vars;
    }

    function PassQueryString()
    {
    boxid = getUrlVars()["boxid"];
    projectName = getUrlVars()["project"];
    alert("ParseQueryString - BoxID :" + boxid);
    alert("ParseQueryString - ProjectName :" + projectName);

    }
    function changeLinkURL()
    {
    boxid = getUrlVars()["boxid"];
    projectName = getUrlVars()["project"];
    linkURL = "C:\Users\Geri\Desktop\test_1.htm + "?boxid=" + boxid + "&projectName=" + projectName";
    }
    function Project(pname)
    {
    location.href=menuURL[pname];
    }


    </script>


    <script type="text/javascript">
    var first = getUrlVars()["boxid"];
    var second = getUrlVars()["project"];
    alert("back button : " + "" + first);
    alert("back button : " + "" + second);
    </script>



    <a href="C:\Users\Geri\Desktop\test_1.htm?boxid=DBB&amp;project=projectName">


    <IMG style="BORDER-BOTTOM: 0px solid;
    BORDER-LEFT: 0px solid; BORDER-TOP: 0px solid; BORDER-RIGHT: 0px solid" border=0
    alt="Back Button" src="C:\Users\Geri\Desktop\test_1.htm/Back%20Button/back_button1.gif">
    </A></P>

    </a>

    <body>
    </body>
    </html>
    Last edited by jordan2000; 08-08-2012 at 04:22 AM.

  • #2
    Regular Coder
    Join Date
    Oct 2011
    Posts
    106
    Thanks
    12
    Thanked 0 Times in 0 Posts
    The first problem I see is with the URL itself. I have not had much luck getting Windows-style directories to work well in a browser. Try replacing C:\Users\Geri\Desktop\test_1.htm with file:///Users/Geri/Desktop/test_1.htm*

    Second, I notice your quotations are not matched:

    linkURL = "C:\Users\Geri\Desktop\test_1.htm + "?boxid=" + boxid + "&projectName=" + projectName"; should be

    linkURL = "C:\Users\Geri\Desktop\test_1.htm" + "?boxid=" + boxid + "&projectName=" + projectName"; **

    And back to the link itself, you shouldn't use an entity for the "&"

    Hope I could help .
    The "getUrlVars()" method you use here would have been helpful to me on my first project, where I had a password protected page (the password was less for actual protection; as my father always says, "locks only keep honest people out"). I ended up needing to set up a localhost server.... backstory over...


    *it might be file:///c/....
    **You could actually cut that part out, making it linkURL = "C:\Users\Geri\Desktop\test_1.htm?boxid=" + boxid + "&projectName=" + projectName";
    Last edited by Scriptr; 08-08-2012 at 06:01 PM.

  • #3
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    passing variables in href tag

    We can pass variable using the ? Symbol.
    for example :

    is we want to send a name and id of a person the we can sent it using the following format.

    name = "Minisuit";
    Id= 1001;
    Now we can send it

    <a href =nextpage.html?FirstName=name&id=id >click Me </a>

    Best Regards,
    Navin Patel
    Last edited by VIPStephan; 08-09-2012 at 02:00 PM. Reason: removed fake signature


  •  

    Posting Permissions

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