Bojak Posted January 15, 2014 Share Posted January 15, 2014 (edited) div #showDate { position:absolute;41px;top:20px; <HTML> <head> <link type="text/css" href="displayDate.css" /> <script type='text/javascript'> function myFunction() { var currentDate = new Date(); var dateTime = (currentDate.getMonth()+1) + "/" + currentDate.getDate() + "/" + currentDate.getFullYear(); document.write(dateTime); //document.getElementById('currentDate').innerHTML = dateTime; Document.cookie = dateTime; document.write(lastVisit); Var lastVisit = document.cookie; } </script> </head> <body> <div id="showDate" style="display:none"> <script type="text/javascript"> myFunction(); </script> </div> <a href="#" onclick="document.getElementById('showDate').style.display = 'block';"> Show Date </a> </body> </HTML> i cant make the date display below the hyperlink. when i tried the above codes the date doesnt appear at all. suggestions? Edited January 15, 2014 by Bojak Quote Link to comment https://forums.phpfreaks.com/topic/285376-css-wont-display/ Share on other sites More sharing options...
JIXO Posted January 15, 2014 Share Posted January 15, 2014 Try this : div #showDate { position: absolute; top: 20px; } <HTML> <head> <link type="text/css" href="displayDate.css" /> <script type='text/javascript'> function myFunction() { var currentDate = new Date(); var dateTime = (currentDate.getMonth()+1) + "/" + currentDate.getDate() + "/" + currentDate.getFullYear(); document.write("Today's date : "); // <- Added this message for explaining what is happining document.write(dateTime); //document.getElementById('currentDate').innerHTML = dateTime; document.cookie = dateTime; var lastVisit = document.cookie; // <- You wrote Var for defining last visit, JavaScript is case sensitive document.write('<br />'); // <- Added this message for explaining what is happining document.write('Last visit : '); // <- Added this message for explaining what is happining document.write(lastVisit); // <- lastVisit was defined after it was printed, which caused the 'undefined' error message } </script> </head> <body> <div id="showDate" style="display:none"> <script type="text/javascript"> myFunction(); </script> </div> <a href="#" onclick="document.getElementById('showDate').style.display = 'block';"> Show Date </a> </body> </HTML> Quote Link to comment https://forums.phpfreaks.com/topic/285376-css-wont-display/#findComment-1465299 Share on other sites More sharing options...
Bojak Posted January 15, 2014 Author Share Posted January 15, 2014 i like the last visit idea. thats exactly my goal. i was working on a cookie to store that. the issue its still above the hyperlink Quote Link to comment https://forums.phpfreaks.com/topic/285376-css-wont-display/#findComment-1465302 Share on other sites More sharing options...
JIXO Posted January 15, 2014 Share Posted January 15, 2014 Just move the showDate div under the hyperlink : <HTML> <head> <link type="text/css" href="displayDate.css" /> <script type='text/javascript'> function myFunction() { var currentDate = new Date(); var dateTime = (currentDate.getMonth()+1) + "/" + currentDate.getDate() + "/" + currentDate.getFullYear(); document.write("Today's date : "); document.write(dateTime); //document.getElementById('currentDate').innerHTML = dateTime; document.cookie = dateTime; var lastVisit = document.cookie; document.write('<br />'); document.write('Last visit : '); document.write(lastVisit); } </script> </head> <body> <a href="#" onclick="document.getElementById('showDate').style.display = 'block';"> Show Date </a> <div id="showDate" style="display:none"> <script type="text/javascript"> myFunction(); </script> </div> </body> </HTML> Quote Link to comment https://forums.phpfreaks.com/topic/285376-css-wont-display/#findComment-1465304 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.