Never been to DZone Snippets before?

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

Passing parameters between pages without servers side scripting (See related posts)

// 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&
Experts Round Table

<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>

You need to create an account or log in to post comments to this site.


Click here to browse all 4858 code snippets

Related Posts