Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hidden asp date in javascript function

Status
Not open for further replies.

denis60

Technical User
Apr 19, 2001
89
CA
Hi!

I want to submit (onclick) in a javascript function and open a new window in it (window.open). But i want to send to the new window the server time of the submit action.
ex.:
<HTML
<BODY BGCOLOR="#FFFFFF">
<SCRIPT language='javascript'>
function popup(){
var token=<%=DateDiff("s", "01/01/1970 00:00:00", Now)%>;
var myString = 'window.open(myString,"test","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=800");
}

<form name="frmMain" method="POST">
<input type="submit" value="submit" name="Submit" onClick="popup(this.form)">
</form>
</BODY>
</HTML>>


The problem in this exemple is the asp part is execute when the page is loaded instead of when the submit is clicked

Is there a way to fix that
 
Since Javascript can only check the time on the client side, you'd have to create a Date() object using the initial server time, then create another Date() on the client computer, using the client computer time. On submission, you again create a date object and get the immediate time, subtract the original client computer time from that to get the difference, and add that to the original server time. That's the only way I've ever figured out to make the client computer handle server time.

Lee
 
Thanks Lee

That what i was looking for
I appreciate your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top