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?

Edited by Bojak
Link to comment
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
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
Share on other sites

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.