63 users online (1 members and 62 guests)  


  Results 1 to 3 of 3

Related

  1. Replies: 0
  2. href + javascript onlick event    Forum: HTML Forum
    Replies: 4
  3. Query String-Dependant Page    Forum: CGI Perl Forum
    Replies: 2
  4. Replies: 5
  5. mysql query / function problem....    Forum: Databases
    Replies: 7
  1. #1
    ghurteau's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2005
    Posts
    2

    Question need help with passing query string to href - javascript function

    need help with passing query string to href - javascript function

    I'm new at playing with html and javascript. I've a script that I want to use to call up and html file, and in this script I want to use a query string to pass info to the html file. The script contains
    iexplore.exe file:Q:/dms2004-sp2/2004/dms/bin/autologin.html?partnumber=$1

    Note $1 gets resolved with a 'real' value withing the script before it gets passed to the html. The html below has a href javascript function autologin, which I am trying to pass the 'partnumber' to, but it is taken literally.
    How do I code the line <a href="javascript:autoLogin('partnumber}')">Log me automatically in</a>, so that partnumber from the query string gets passed into the autologin function?
    Code:
     
    <html>
    <head>
    <script type="text/javascript">
    function autoLogin(pn) {
    document.frmFTZ.submit();
    window.open("http://www.partminer.com/servlet/DesignCenter?partnumber=" + pn ,"remote"); } 
    </script>
    </head>
    
    <a href="javascript:autoLogin('partnumber}')">Log me automatically in</a>
    <body>
    <form name="frmFTZ" method=post action="http://www.partminer.com/servlet/Login"> 
    <input type=hidden id=UserName name="txtemailaddress" value="<A href="mailto:*******@*******"></input">*******@*******"></input> 
    <input type=hidden id=Password name="txtpassword" value="********"></input> 
    </form>
    </body>
    </html>
    Last edited by HTML; 10-11-2005 at 10:51 AM. Reason: insert code tags

  2. #2
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: need help with passing query string to href - javascript function

    this code gets the info after "partnumber=", but you will have to modify it to allow it to have more than 1 variable in the url!

    HTML Code:
    var url = String(document.location);
    alert(url.substring(url.indexOf('partnumber')+11, url.length));

  3. #3
    ghurteau's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2005
    Posts
    2

    Thumbs up Re: need help with passing query string to href - javascript function

    Found the following the solution at
    http://www.codingforums.com/showthread.php?t=69675

    Use this http://www.codingforums.com/showthread.php?t=25786 Parse Query String script. You would use it this way:


    Code:
    var pqs = new ParseQueryString();
    
     
    function autoLogin() {
    document.frmFTZ.submit();
    var pn = pqs.param("partnumber");
    window.open("http://www.partminer.com/servlet/DesignCenter?partnumber=" + pn ,"remote"); 
    } 
    ...
    <a href="javascript:autoLogin()">Log me automatically in</a>
    Last edited by HTML; 10-11-2005 at 10:50 AM. Reason: insert code tags



Tags for this Thread