www.webdeveloper.com
Results 1 to 2 of 2

Thread: show image depending on date range

  1. #1
    Join Date
    May 2014
    Posts
    4

    show image depending on date range

    Hello, I diplay an image on my page, and user jquery script to show another image when mouse rollovers.

    However I would like to show one image only during certain date range that can be configured like 2014-05-01 to 2014-07-01 etc.

    Else another "expired" image needs to be shown.

    My current code is like this:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>URL Screenshot Preview with jQuery</title>
    <meta name="description" content="Easiest jQuery Tooltip Ever">
    <script src="http://www.gamafix.lt/badge/jquery.js" type="text/javascript"></script>
    <script src="http://www.gamafix.lt/badge/main.js" type="text/javascript"></script>
    </meta>
    
    
    <style>
    body {
    	margin:0;
    	padding:40px;
    	background:#fff;
    	font:80% Arial, Helvetica, sans-serif;
    	color:#555;
    	line-height:180%;
    }
    
    h1{
    	font-size:180%;
    	font-weight:normal;
    	color:#555;
    }
    h2{
    	clear:both;
    	font-size:160%;
    	font-weight:normal;
    	color:#555;
    	margin:0;
    	padding:.5em 0;
    }
    a{
    	text-decoration:none;
    	color:#f30;	
    }
    p{
    	clear:both;
    	margin:0;
    	padding:.5em 0;
    }
    pre{
    	display:block;
    	font:100% "Courier New", Courier, monospace;
    	padding:10px;
    	border:1px solid #bae2f0;
    	background:#e3f4f9;	
    	margin:.5em 0;
    	overflow:auto;
    	width:800px;
    }
    
    img{border:none;}
    ul,li{
    	margin:0;
    	padding:0;
    }
    li{
    	list-style:none;
    	float:left;
    	display:inline;
    	margin-right:10px;
    }
    
    
    
    /*  */
    
    #screenshot{
    	position:absolute;
    	border:1px solid #ccc;
    	background:#333;
    	padding:5px;
    	display:none;
    	color:#fff;
    	}
    
    /*  */
    </style>
    </head>
    <body>
    
    	<a href="http://www.gamafix.lt" title="www.gamafix.lt - Spalvu Valdymo Sprendimai" class="screenshot" rel="http://www.gamafix.lt/badge/2014-klp-1.png" target="_blank"><img src="http://www.gamafix.lt/badge/ISO12647-2.png" alt="Spaudos sertifikacija" width="150" height="116" border="0"></a>
    		
    		
    </body>
    </html>

  2. #2
    Join Date
    May 2014
    Posts
    4
    This date interval code works OK, but I would like to add year check and how do I make it a single script?

    Code:
    <html> 
    <head> 
    
    <script language="javascript"> 
    <!-- 
    var picture='';
    mytime=new Date(); 
    mymonth=mytime.getMonth()+1; 
    mydate=mytime.getDate(); 
    if (mymonth==5 && mydate<=30) {picture="<img src=image to show.png>"}
    else if (mymonth==6 && mydate<=30) {picture="<img src=image to show.png>"} 
    else {picture="<img src=image to show else case.png>"
    }
    //--> 
    </script> 
    
    
    </head> 
    <body> 
    <table> 
    <tr> 
    <td> 
    <script language="javascript"> 
    if(picture!='')
    {
    document.write(picture); 
    }
    
    </script> 
    
    </td> 
    </tr> 
    </table> 
    </body>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles