0

I want to keep the value of the user input (e.g. text box value) displayed after page refresh by a javascript.
The following test web page is used.
The alerts appear before and after the page refresh as expected on all browsers (FF, Chrome, Opera & IE).
The input value in a text box still appear after page refresh for IE but not FF, Chrome, Opera.
Please help to make it work for FF, Chrome, Opera.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <link rel="stylesheet" type="text/css" media="all" href="css/style.css" />
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <title>Cookie</title>
   </head>
   
   <body>
      <div>
         <br>
         Rows Per Page
         <input type="text" name="rowsPerPage" id="rowsPerPage" />
         <input type="submit" value="savevalue" onClick="savevalue()">
      </div>
      <script type="text/javascript" src="js/prototype.js"></script>
      <script type="text/javascript" src="js/Cookie.js"></script>
      <script type="text/javascript">
         Cookie.init({name: 'mydata'});

         function savevalue() {
            var rowsPerPageElem = document.getElementById("rowsPerPage");
            alert('rowsPerPageElem.value ' + rowsPerPageElem.value);
            Cookie.setData('rowsPerPage', rowsPerPageElem.value);

            window.location.reload(true);
            var rowsPerPage = Cookie.getData('rowsPerPage');

            alert(' rowsPerPage ' + rowsPerPage);

            var rowsPerPageElem = document.getElementById("rowsPerPage");
            rowsPerPageElem.value = rowsPerPage;
         }
      </script>
   </body>
</html>

Edited by albertkao: n/a

2
Contributors
2
Replies
5
Views
7 Years
Discussion Span
Last Post by albertkao
0

I may have to pass because I do not have access to your Cookie.js. I do not know what kind of the object created by the js file. As a result, I have no idea how it is implemented and cannot do the test of your provided code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.