Solved

One day session for checkbox

Posted on 2013-05-26
6
338 Views
Last Modified: 2013-05-30
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
Comment
Question by:RickardP_GSI
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 

Author Comment

by:RickardP_GSI
ID: 39198285
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
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39198311
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
 

Author Comment

by:RickardP_GSI
ID: 39198419
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
Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

 

Author Comment

by:RickardP_GSI
ID: 39198448
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
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39198489
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
 

Author Closing Comment

by:RickardP_GSI
ID: 39208658
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question