469,306 Members | 1,850 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Creating temporary links that expire?

I am developing a web site for a summer comedy series. The site has
links to buy tickets but I want them to disappear two hours before the
show begins. Does anyone know how to use a simple javascript that
shows and hides text and links after a date has passed?

lee317
Jul 23 '05 #1
3 5428
Lee
Levi said:

I am developing a web site for a summer comedy series. The site has
links to buy tickets but I want them to disappear two hours before the
show begins. Does anyone know how to use a simple javascript that
shows and hides text and links after a date has passed?


This example only hides the "buy" link after the date has passed
(it actually checks to see if it's within 2 hours of the data/time).
It assumes that you and your customers are within the same time
zone and that there won't be a Daylight Saving Time change just
before showtime. Older browsers and browsers that have javascript
disabled will still see the link.
<html>
<head>
<script type="text/javascript">
var TWO_HOURS=7200000;
function checkExpiry(img,dateString){
var showTime=new Date(dateString);
var now=new Date();
if(img.parentNode && (showTime-now)<TWO_HOURS){
img.parentNode.style.visibility="hidden";
}
}
</script>
</head>
<body>
<table>
<tr>
<td>Show 1</td>
<td><a href="linkToBuyTickets.html"><img border="0"
src="http://www.azphx.com/dhtml/tmp/buy5025.gif"
onload="checkExpiry(this,'Mon, 25 Dec 1995 13:30')"></a>
</td>
</tr>
<tr>
<td>Show 2</td>
<td><a href="linkToBuyTickets.html"><img border="0"
src="http://www.azphx.com/dhtml/tmp/buy5025.gif"
onload="checkExpiry(this,'Mon, 25 Dec 2004 13:30')"></a>
</td>
</tr>
</table>
</body>
</html>

Jul 23 '05 #2
you could also do it in php.
check php.net for date-calculation functions
Jul 23 '05 #3
Thanks so much...this is perfect!

Lee <RE**************@cox.net> wrote in message news:<c9*********@drn.newsguy.com>...
Levi said:

I am developing a web site for a summer comedy series. The site has
links to buy tickets but I want them to disappear two hours before the
show begins. Does anyone know how to use a simple javascript that
shows and hides text and links after a date has passed?


This example only hides the "buy" link after the date has passed
(it actually checks to see if it's within 2 hours of the data/time).
It assumes that you and your customers are within the same time
zone and that there won't be a Daylight Saving Time change just
before showtime. Older browsers and browsers that have javascript
disabled will still see the link.
<html>
<head>
<script type="text/javascript">
var TWO_HOURS=7200000;
function checkExpiry(img,dateString){
var showTime=new Date(dateString);
var now=new Date();
if(img.parentNode && (showTime-now)<TWO_HOURS){
img.parentNode.style.visibility="hidden";
}
}
</script>
</head>
<body>
<table>
<tr>
<td>Show 1</td>
<td><a href="linkToBuyTickets.html"><img border="0"
src="http://www.azphx.com/dhtml/tmp/buy5025.gif"
onload="checkExpiry(this,'Mon, 25 Dec 1995 13:30')"></a>
</td>
</tr>
<tr>
<td>Show 2</td>
<td><a href="linkToBuyTickets.html"><img border="0"
src="http://www.azphx.com/dhtml/tmp/buy5025.gif"
onload="checkExpiry(this,'Mon, 25 Dec 2004 13:30')"></a>
</td>
</tr>
</table>
</body>
</html>

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by John Baker | last post: by
1 post views Thread by Donald | last post: by
4 posts views Thread by Nicolás Castagnet | last post: by
reply views Thread by aspineux | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.