SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to Pass Querystring between two html pages using javascript

    hello guys..

    can anybody guide me how to pass querystring between two HTML pages.
    from page1.html -->

    page2.html?s=232&cRes=sbd134&UserId=myid&CustCode=DT

    this will be received on page2.html

    the code i have found for page2.html is...

    Code:
    var qsParm = new Array();
    
    function qs() 
    {
    
    qsParm['s'] = null;
    qsParm['cRes'] = null;
    qsParm['UserID'] = null;
    qsParm['CustCode'] = null;
    
    var query = window.location.search.substring(1);
    var parms = query.split('&');
    for (var i=0; i<parms.length; i++) 
    {
    var pos = parms[i].indexOf('=');
         if (pos > 0)
         {
                var key = parms[i].substring(0,pos);
                var val = parms[i].substring(pos+1);
                qsParm[key] = val;
         } //end of if
    
    } // end of for
    
    } //end of function
    
    
    the value of qsParm['CustCode'], need to be utilize in another javascript
    the code is followed
    
           <script type="text/javascript" language="">
    		<!--
    
    		d = new dTree('d');
    
    		d.add(0,-1,'Online Reports');
    
    		d.add(1,0,'Transactions','javascript:d.o(1);');
    		
    		d.add(2,1,'ASN','http://www.mysite.com/asn.php?CustCode=value of qsPram['CustCode']','Advance Shipping Note','');
    		d.add(3,1,'Orders','javascript:alert(\'Under Construction\');','','');
    		
    		d.add(4,0,'View / Print','javascript:d.o(4);');
    
    		d.add(5,4,'GRN','javascript:alert(\'Under Construction\');','Goods Receipt Note','');
    		d.add(6,4,'GDN','javascript:alert(\'Under Construction\');','Goods Dispatch Note','');
    
    		d.add(7,0,'Reports','javascript:d.o(7);');
    
    		d.add(8,7,'Report 1','javascript:alert(\'Under Construction\');','','');
    		d.add(9,7,'Report 2','javascript:alert(\'Under Construction\');','','');
    		d.add(10,7,'Report 3','javascript:alert(\'Under Construction\');','','');
    
    		document.write(d);
    
    		//-->
    	
      </script>
    Please Help...

    Saifee S L

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does your code work?

    For reference, here is what I use: xGetURLArguments


Bookmarks

Posting Permissions

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