Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2000-03-03
6
Medium Priority
?
210 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 200 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

864 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