View Single Post
Old 01-04-2017, 10:35 PM  
Bladewire
StraightBro
 
Bladewire's Avatar
 
Industry Role:
Join Date: Aug 2003
Location: Monarch Beach, CA USA
Posts: 56,232
Quote:
Originally Posted by sarettah View Post
Here is a working example: http://madspiders.com/js_test/page1.htm

On Page 1 enter something in the text box and then hit the link to page 2. On page 2, whatever you entered on page 1 will be displayed.

Code for Page 1:

Code:
<html>
  <head>
  <title></title>
  <script type=text/javascript>

  function storeit(stored_data)
  {
    sessionStorage.setItem('stored_data', stored_data);
  }    
  
  </script>
  </head>
  <body>
    Enter something here:  <input type=text value='' width=20 maxlength=50 onChange="storeit(this.value)";><br>
    <a href=page2.htm>Go to Page 2</a>
  </body>
</html>
Code for page 2:

Code:
<html>
  <head>
  <title></title>
  <script type=text/javascript>

  function get_data()
  {
    var stored_data = sessionStorage.getItem('stored_data');
    if(stored_data>'')
    {
      result_div.innerHTML='data stored was: ' + stored_data + '<br>';
    }
    else
    {
      result_div.innerHTML='no data was found<br>';
    }
  }    
  
  </script>

  </head>
  <body>
  <div name=result_div id=result_div>
  </div>
  </body>
  <script type=text/javascript>
    get_data();
  </script>  
</html>
.


^^ Verified super brains much respect ^^
Bladewire is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote