Jump to content


Photo

CSS wont display


  • Please log in to reply
3 replies to this topic

#1 Bojak

Bojak

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts

Posted 14 January 2014 - 07:22 PM

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, 14 January 2014 - 07:35 PM.


#2 JIXO

JIXO

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts

Posted 14 January 2014 - 07:47 PM

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>


#3 Bojak

Bojak

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts

Posted 14 January 2014 - 08:17 PM

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



#4 JIXO

JIXO

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts

Posted 14 January 2014 - 08:26 PM

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>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com