473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 6512
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: gonzal | last post by:
Hi Dose any body know why a temporary table gets deleted after querying it the first time (using SELECT INTO)? When I run the code bellow I'm getting an error message when open the temp table...
10
by: Ranga | last post by:
I was unable to run the statement "CREATE GLOBAL TEMPORARY TABLE" on unix version of DB2, it gave the follwing error db2 => create global temporary table temp ( OGI_SYS_NR char(8) ) DB21034E ...
7
by: John Baker | last post by:
Hi: I would like to know how to create a temp DB to store the data in a table while I do something else with the table. Specifically, how do I create the temp remove the temp I want to be...
1
by: Donald | last post by:
How do I prevent I WebForm from being cached in the "Temporary Internet Files" folder on the client computer? The web form is displayed in a popup modal dialog (window.showModalDialog). If the...
4
by: Nicolás Castagnet | last post by:
Hi, I write this post because I notice a strange behavior related with "Temporary Internet Files" and maybe some of you can help me to understand it. I am working in a web application with...
1
by: umamy | last post by:
Hi, I am writing code to do the followin: - user clicks a link - the page reloads and sets a cookie with a js function in the header. The function reloads the same page with the cookie set and...
0
by: aspineux | last post by:
setacl and getacl look to be already "Cyrus" specific (according the doc), why not to extend imaplib a little bit more ? Here are some code I wrote and tested to support cyrus "expire" that...
11
by: rawu | last post by:
hi , all . I got a question about creating indexes in db2 . a table has 44236333 rows an index planed to be build include 2 field ( 6 byte ) accordding to db2 document temporary...
10
by: Jess | last post by:
Hello, If I create a temporary object using a dynamically created object's pointer, then when the temporary object is destroyed, will the dynamically created object be destroyed too? My guess...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.