Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2000-03-03
6
Medium Priority
?
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

609 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