Jump to content

CSS wont display


Bojak

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/285376-css-wont-display/
Share on other sites

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>
Link to comment
https://forums.phpfreaks.com/topic/285376-css-wont-display/#findComment-1465299
Share on other sites

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>
Link to comment
https://forums.phpfreaks.com/topic/285376-css-wont-display/#findComment-1465304
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.