• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 342
  • Last Modified:

One day session for checkbox

I have this code in the page and it works great - however, I don't want the user to have to keep clicking this box once they have clicked it initially - I'd like the 'session' to last a day.

Please help:

<script>
function redirect(checkbox) {

if (checkbox.checked) {

window.location = 'Training-Resource-Library.htm';

}
}
</script>

<script language="JavaScript" fptype="dynamicanimation">
<!--
function dynAnimation() {}
function clickSwapImg() {}
//-->
</script>
<script language="JavaScript1.2" fptype="dynamicanimation" src="animate.js">
</script>

</head>

<body onload="dynAnimation()">



<p>&nbsp;</p>
<p>&nbsp;</p>


<input type='checkbox' onclick="javascript: redirect(this)" value="ON">&nbsp;&nbsp;&nbsp;&nbsp; <input type="submit" value="I ACCEPT THESE TERMS" name="B1">


</body>
0
RickardP_GSI
Asked:
RickardP_GSI
  • 4
  • 2
1 Solution
 
RickardP_GSIAuthor Commented:
Or better yet - I'd like this page to only show once - then when the user clicks the checkbox - it redirects them to a page - but I want the session for these two pages to last one day - so user doesn't have to keep clicking the checkbox each time the page shows up.
TEST.html
acceptTerms.js
0
 
Dave BaldwinFixer of ProblemsCommented:
The standard way would be to set a cookie in the user's browser that expires in 24 hours.  Then every time they go to your pages, you check to see if it has expired or doesn't exist which is what happens when it expires.  If it's still good, you continue with the page.  If not you send them to the 'accept' page.

http://www.w3schools.com/js/js_cookies.asp

Although your code probably works, it is not using the currently accepted attributes for javascript sections.  You can look at the source for this page for more examples.
<script type="text/javascript">
... your code...
</script>
Or...
<script  type="text/javascript" src="animate.js"></script>

Open in new window

0
 
RickardP_GSIAuthor Commented:
Ok i got the javascript worked out -  I just want the user to come to the page, accept the checkbox, continue to the designated page, and not have to keep checking the box  when they click back on this link -i don't want them to have to fill in their name, etc., just accept the terms, check the box, and move to another page.
TEST2.html
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RickardP_GSIAuthor Commented:
once the user has accepted the terms and checked the box, the users gets directed to www.pavilioncafe.com - what i want it after they close the browser and they go back to the pavioioncafe.com - they don't have to check the accepted terms box.  I'm not even sure I have this set up correctl - and my brain is fried
0
 
Dave BaldwinFixer of ProblemsCommented:
Without setting a cookie and checking it, there is no way.  It's too late for me to do anymore on it tonight.  Maybe tomorrow.
0
 
RickardP_GSIAuthor Commented:
I wasn't totally happy with the solution - I gave up - but now don't have time to deal with it - thank you
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now