?
Solved

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

Posted on 2000-03-03
6
Medium Priority
?
207 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
Industry Leaders: 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!

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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.
Suggested Courses

764 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