Click to see the days left
<script> function cdtime( targetdate){ var currentTime=new Date() var tdate=new Date(targetdate) var timesup=false var timediff=(tdate - currentTime)/1000 var oneHour=3600 //hour unit in seconds var oneDay=86400 //day unit in seconds var oneMonth=2630880 //month unit in seconds var oneYear=31570560 var yearfield=Math.floor(timediff/oneYear) timediff = timediff - (yearfield * oneYear) var monthfield=Math.floor(timediff/oneMonth) timediff = timediff - (monthfield * oneMonth) var dayfield=Math.floor(timediff/oneDay) timediff = timediff - (dayfield * oneDay) var hourfield=Math.floor(timediff/oneHour) if (currentTime >= tdate){ var ret = "The time is up!" }else{ if (yearfield > 1){ret = yearfield + " Years " }else{ret = yearfield + " Year "} if (monthfield > 1){ret = ret + monthfield + " Months "}else{ret = ret + monthfield + " Month "} if (dayfield > 1){ret = ret + dayfield + " days and " }else{ret = ret + dayfield + " day and " } if (hourfield > 1){ret = ret + hourfield + " Hours left"}else{ret = ret + hourfield + " Hour left"} } return ret } </script>
To call it just place this code on your page.
document.write(cdtime("July 1, 2010"))
There are several ways to handle file download.
The best ways due to speed and Browser compatibility are third party upload/download products.
Two of the most popular are Persits ASPUpload and SA's Fileup.
These examples will show typical code associated with both.
For Persits:
To visit their Web Site Persits Software
Version 2 is a problem with some browsers - I suggest using version 3
on error resume next
Dim s_filename, s_filepath, s_fullpath
s_filename = Request.QueryString("file_name")
S_filepath = server.MapPath("sub_directory_name") & "\"
S_fullpath = filepath & filename
Set obj_Upload = Server.CreateObject("Persits.Upload")
if err = 0 then
obj_Upload.SendBinary fullpath, True, "application/octet-stream", True ' (version 3)
' obj_Upload.SendBinary fullpath, True, "application/octet-stream" '(version 2)
else
response.write(err.Description)
end if
if err then response.write("An Error has occurred - Please contact us - Error:" & err.Description)
set obj_Upload = nothing
For SA Fileup:
To visit their Web Site SoftArtisans
Dim s_filename, s_filepath, s_fullpath, oFS, oF
s_filename = Request.QueryString("file_name")
S_filepath = server.MapPath("sub_directory_name") & "\"
S_fullpath = filepath & filename
Response.Addheader "Content-Disposition", "Attachment; filename=" & filename
Response.ContentType = "application/pdf"
fullpath = filepath & filename
set oFS = Server.CreateObject("Scripting.FileSystemObject")
set oF = oFS.GetFile(fullpath)
Response.AddHeader "Content-Length", oF.Size
set oF = nothing
set oFS = nothing
Set download = Server.CreateObject("SoftArtisans.FileUp")
download.TransferFile fullpath
set download = nothing
Now if you don't have either of these or any other third party tools then we have two other ways to set your download.
Using simple script:
This works but it is slow to start with large files so your user may think your script is bad or that his browser died.
You also must use "application/octet-stream" as the mime type else the browser may open the file rather than download it.
ASP
on error resume next
filename = Request.QueryString("filenm")
Dim s_filename, s_filepath, s_fullpath
s_filepath = server.MapPath("catalog") & "\"
s_fullpath = filepath & filename
set oFS = Server.CreateObject("Scripting.FileSystemObject")
Set oF = oFS.OpenTextFile( fullpath, 1, False )
If oFS.FileExists( fullpath ) Then
Response.Addheader "Content-Disposition", "Attachment; filename=" & filename
Response.ContentType = "application/octet-stream"
While Not Bin.AtEndOfStream
Response.BinaryWrite( ChrB( Asc( Bin.Read( 1 ) ) ) )
Wend
Else
Response.Redirect( "file_error.asp?fln=" & fullpath )
End If
Bin.Close
Set Bin = Nothing
set oFS = nothing
Simple download using .NET
For this one you must save the script as .aspx in order for it to work and your server must support .net
It is almost perfect in operation as an alternative to third party software.
Dim s_filename, s_fullpath
s_filename = Request.QueryString("file_name")
s_fullpath = Request.PhysicalApplicationPath & "catalog/" & filename
Response.Addheader("Content-Disposition", "Attachment; filename=" & s_filename )
Response.ContentType = "application/pdf"
Response.WriteFile (s_fullpath)
PHP
Check our download section for a PHP download script.
Many in the RS World are turning to the XML Parser from MicroSoft
Using XMLHTTP you can acomplish remote scripting but there are pit falls.
The biggest pitfall is calling a page in the same directory will crash the server.
There is nothing to install or download, the parser is supported by most browsers
JSRS:
This method uses an Iframe to accomplish similar functionality.
Other than this problem with the history bug in Netscape - JSRS works fine. Any browser that supports Ifames will work fine with JSRS and since the Iframe is now a standard I believe this is the better choice of the two.
For Compatibility with all browsers JSRS offers RSLite - This one uses image/cookie method to accomplish Remote Scripting.
If you are setting up a Internet or Intranet site and really don't need to use SQL Server or Oracle as your database - Access may just do the trick.
The only problem is when you need to modify the database or import data.
The question becomes how do you do it.
You don't want to overwrite the database file because this can be a problem.
Should users be logged on at the time you decide to replace it you will run into trouble.
The best way is to use a remote access utility. There are a few on the market that serve this purpose but you might want to look into a product called Cute ASP Table Editor.
This one can be downloaded free from: http://sourceforge.net/projects/cuteasp/
One method we can use is using a table with the picture as the background
We can set the background for the column and place the text within the TD tag as normal <td background="mars_lander.gif" width="231" height="265" align="center" nowrap> <h1><font color="yellow">Is there Life on Mars?</font></h1></td> |
Is there Life
|
Another method we can use is using position or layers
For this example We will use the div tag
<div class="div_set"><br><br>Is there Life<br>on Mars?</div>
For the Style we have the following:
<STYLE> .div_set {z-index:1; background-image: url(mars_lander.gif); font-size:34; font-weight:bold; text-Align:center; color: yellow; position:relative; width: 231; height:265;} </STYLE>
Is there Life
on Mars?
In both cases to avoid repeating the image use background-repeat:no-repeat
Vincent Gabriele