Solved

Interaction between javascript (client side) & asp vbscript on same page

Posted on 2000-03-03
6
199 Views
Last Modified: 2013-11-19
I need to use javascript in an asp page to get the client side date instead of the server.  I can do this and print it on screen.  I then need to use thaat date to go to the server database and get stuff.  I don't seem to be able to call javascript functions from within my asp code so how do I get a value in a variable in the asp code that is equal to the client side date??

Probably easy for someone who knows what they're doing!
0
Comment
Question by:carled
6 Comments
 
LVL 9

Expert Comment

by:TTom
ID: 2581865
Seems to me that the problem is not one of language, but of logic.  All your ASP code is processed before anything is sent to the client.  Once the page is sent to the client, the server is "disconnected".

What you could probably do is to send down the page to the client, get the date information at the client, and then "resubmit" the page (as a form) to itself, passing in the client information.

In any case, you are going to have to make another round trip to the server in order to use client side information.

HTH,

Tom
0
 
LVL 8

Expert Comment

by:jbirk
ID: 2583094
You can send client side information via a 1X1 transparent gif with arguments.  I've done this to get a tracker and counter program working.  I use perl to parse the info and return the transparent gif though...


-Josh
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 50 total points
ID: 2584415
Here's an implementation of Ttom's suggestion:

test.asp
--------
<%
if request.querystring("d") = "" then
%>
<HTML>
<script language="javascript">
d = new Date();
document.write("<body onload=\"location.href='test.asp?d=" + d + ";'\"></body>");
</script>
</html>
<% else %>
<html>
<body>
The client thinks it's <%=request.querystring("d")%>
</body>
</html>
<% end if %>

You can also use the single pixel method that Josh suggested under ASP, but you still have the same problem that TTom mentioned-- it requires a trip to the server, so it's not going to be available for the page that it's being displayed on.

You could also use remote scripting.  See the following:

  http://msdn.microsoft.com/scripting/default.htm?/scripting/remotescripting/default.htm
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 1

Author Comment

by:carled
ID: 2585367
Thanks clockwatcher.

Thanks also TTom.  I've given the points to clockwatcher because of the sample script and helpful link.
0
 
LVL 25

Expert Comment

by:clockwatcher
ID: 2585425
Thanks.

BTW, I should have escaped the querystring variable.

document.write("<body onload=\"location.href='test.asp?d=" + escape(d) + ";'\"></body>");


0
 
LVL 9

Expert Comment

by:TTom
ID: 2587667
Most welcome.

Tom
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now