Advertisement
Guest User

Untitled

a guest
Sep 30th, 2010
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. /*
  5. Cookie script - Scott Andrew
  6. Popup script, Copyright 2005, Sandeep Gangadharan
  7. */
  8.  
  9. function newCookie(name,value,days) {
  10. var days = 10; // the number at the left reflects the number of days for the cookie to last
  11. // modify it according to your needs
  12. if (days) {
  13. var date = new Date();
  14. date.setTime(date.getTime()+(days*24*60*60*1000));
  15. var expires = "; expires="+date.toGMTString(); }
  16. else var expires = "";
  17. document.cookie = name+"="+value+expires+"; path=/"; }
  18.  
  19. function readCookie(name) {
  20. var nameSG = name + "=";
  21. var nuller = '';
  22. if (document.cookie.indexOf(nameSG) == -1)
  23. return nuller;
  24.  
  25. var ca = document.cookie.split(';');
  26. for(var i=0; i<ca.length; i++) {
  27. var c = ca[i];
  28. while (c.charAt(0)==' ') c = c.substring(1,c.length);
  29. if (c.indexOf(nameSG) == 0) return c.substring(nameSG.length,c.length); }
  30. return null; }
  31.  
  32. function eraseCookie(name) {
  33. newCookie(name,"",1); }
  34.  
  35. function toMem(a) {
  36. newCookie('theName', document.form.name.value); // add a new cookie as shown at left for every
  37. newCookie('theEmail', document.form.email.value); // field you wish to have the script remember
  38. }
  39.  
  40. function delMem(a) {
  41. eraseCookie('theName'); // make sure to add the eraseCookie function for every field
  42. eraseCookie('theEmail');
  43.  
  44. document.form.name.value = ''; // add a line for every field
  45. document.form.email.value = ''; }
  46.  
  47.  
  48. function remCookie() {
  49. document.form.name.value = readCookie("theName");
  50. document.form.email.value = readCookie("theEmail");
  51. }
  52.  
  53. // Multiple onload function created by: Simon Willison
  54. // http://simon.incutio.com/archive/2004/05/26/addLoadEvent
  55. function addLoadEvent(func) {
  56. var oldonload = window.onload;
  57. if (typeof window.onload != 'function') {
  58. window.onload = func;
  59. } else {
  60. window.onload = function() {
  61. if (oldonload) {
  62. oldonload();
  63. }
  64. func();
  65. }
  66. }
  67. }
  68.  
  69. addLoadEvent(function() {
  70. remCookie();
  71. });
  72.  
  73. </script>
  74. <!--
  75. This script downloaded from www.JavaScriptBank.com
  76. Come to view and download over 2000+ free javascript at www.JavaScriptBank.com
  77. -->
  78. </head>
  79. <body>
  80. <form name="form" action="" method="post" onsubmit="if (this.checker.checked) toMem(this)">
  81. <table border="0" cellpadding="0" cellspacing="3" align="center" width="460">
  82. <tr>
  83. <td width="170" align="right">
  84. Name:
  85. </td>
  86. <td width="290">
  87. <input size="30" name="name" id="name">
  88. </td>
  89.  
  90. </tr>
  91. <tr>
  92. <td width="170" align="right">
  93. E-mail:
  94. </td>
  95. <td width="290">
  96. <input size="30" name="email" id="email">
  97. </td>
  98. </tr>
  99.  
  100. <tr>
  101. <td width="170" align="right">
  102. Remember me?:
  103. </td>
  104. <td width="290">
  105. <input type="checkbox" id="checker" name="checker">
  106. </td>
  107. </tr>
  108. <tr>
  109.  
  110. <td colspan="2" align="center">
  111. <input type="submit" value="Submit">
  112. <input type="reset" value="Reset">
  113. <input type="button" onclick="delMem(this)" value="Delete Information">
  114. </td>
  115. </tr>
  116. </table>
  117. </form>
  118. <!--
  119. This script downloaded from www.JavaScriptBank.com
  120. Come to view and download over 2000+ free javascript at www.JavaScriptBank.com
  121. -->
  122.  
  123. </body>
  124. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement