Connecting Tech Pros Worldwide Help | Site Map

Creating temporary links that expire?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 11:24 AM
Levi
Guest
 
Posts: n/a
Default 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

  #2  
Old July 23rd, 2005, 11:25 AM
Lee
Guest
 
Posts: n/a
Default Re: Creating temporary links that expire?

Levi said:[color=blue]
>
>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?[/color]

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>

  #3  
Old July 23rd, 2005, 11:25 AM
Matthias H. Risse
Guest
 
Posts: n/a
Default Re: Creating temporary links that expire?

you could also do it in php.
check php.net for date-calculation functions
  #4  
Old July 23rd, 2005, 11:25 AM
Levi
Guest
 
Posts: n/a
Default Re: Creating temporary links that expire?

Thanks so much...this is perfect!

Lee <REM0VElbspamtrap@cox.net> wrote in message news:<c9u56v025st@drn.newsguy.com>...[color=blue]
> Levi said:[color=green]
> >
> >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?[/color]
>
> 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>[/color]
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.