DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Roy has posted 10 posts at DZone. View Full User Profile

Passing Parameters Between Pages Without Servers Side Scripting

03.01.2007
| 8946 views |
  • submit to reddit
        // description of your code here
Sometimes you need to pass parameters directly between pages for dynamic effect. This is the way to process those on the receiving page.  The arguments can be added directly onto the url or a form with a get method caa be used.  As long as the server just passs the request through the receiving page can use the parameters to present alternate presentations, pre-populate form eleemnts, or just carry through the values for a multi-page form.

Cd&
<a href="http://www.expertsrt.com"> Experts Round Table </a>
 
<html> 
<head> 
<script type="text/javascript"> 
   parmarr = new Array;
   valuearr = new Array;
   function readparms()
   {
      if(location.search!='')
      { 
         Args = location.search.substring(1); 
         parmarr = Args.split('&');
         for(i=0;i<parmarr.length;i++)
         {
            valuearr[i] = parmarr[i].split('='); 
         }
      } 
   }
</script> 
</head> 
<body onLoad="readparms();showparms();"> 
<script type="text/javascript">
   // all this script does is display the parms but the
   // stored values can be used by any function
   function showparms()
   { 
      if(location.search!='')
      { 
         for(i=0;i<valuearr.length;i++)
         {
            document.write(valuearr[i][0] +'=' +valuearr[i][1] +'<br>'); 
         }
      } 
   } 
</script>  
</body> 
</html>