Solved

One day session for checkbox

Posted on 2013-05-26
6
331 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
  • 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 82

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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 82

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now