Jump to content

Recommended Posts

<HTML>
	<head>
        <title>Last Visit Cookie Tester</title>
		<script type='text/javascript'>
			function myFunction() {
		   		var currentDate = new Date();
           		var dateTime = (currentDate.getMonth()+1) + "/" + currentDate.getDate() + "/" + currentDate.getFullYear();
           		document.write("Current Date: " + dateTime);
           		document.write("<br>");
           		document.write("<br>");
           		document.write("<br>");
           		document.cookie = dateTime;
				var lastVisit = document.cookie;
				document.write("Last Visit: " + lastVisit);
           	}
                    if (dateTime !=="") {
                     
                       document.write("window.dateTime");
                       alert("Passed! you are awesome!"); 
 
              else {
                       alert("failed. try again!"); 
}
 


} 
		</script>
	</head>               

	<body>
		<div id="showDate" style="display:none; " >
			<script type="text/javascript">
 		    	myFunction();
			</script>
    	</div>
    	
    	<div style="position:absolute; top:20px; left:20px;">
			<a href="#" onclick="document.getElementById('showDate').style.display = 'block';"> Show Date </a>
		</div>
	</body>              
</HTML>

my if statement isnt working properly. i want to parse the information if the cookie isnt null. guidiance would help so much! 

Link to comment
https://forums.phpfreaks.com/topic/285380-error-checking-in-javascript/
Share on other sites

<HTML>
	<head>
        <title>Last Visit Cookie Tester</title>
		<script type='text/javascript'>
			function myFunction() {
		   		var currentDate = new Date();
           		var dateTime = (currentDate.getMonth()+1) + "/" + currentDate.getDate() + "/" + currentDate.getFullYear();
           		document.write("Current Date: " + dateTime);
           		document.write("<br>");
           		document.write("<br>");
           		document.write("<br>");
           		document.cookie = dateTime;
				var lastVisit = document.cookie;
				document.write("Last Visit: " + lastVisit);
           	}
                    if (dateTime !="") {
                     document.cookie = dateTime;
                     //  document.write("window.dateTime");
                       alert("Passed! you are awesome!"); 
 }
              else {
                       alert("failed. try again!"); 
}
 



		</script>
	</head>               

its suppose to post passed in an alert if it not null. im using the alert box as a way to test it. it doesnt seem to help. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.