Quicky JScript question...

There’s got to be an easy way to do this.

I have a jscript var loaded into a frame. I want to access it from a vbscript .asp.

For instance.

<SCRIPT LANGUAGE=JAVASCRIPT>

var NEWVALUE = parent.MapFrame.XMLPPIOrder;

</SCRIPT>

<%

I need to get the NEWVALUE variable into this section of the vbscript .asp page.

Can I somehow pass it over the </SCRIPT> tag?

Call a javascript function from .asp ?

Call it directly from .asp?

Something?

Thanks.

I am still learning more about ASP, so take this with a grain of salt (maybe someone with more experience can chime in on this):

Since the Javascript is run on the client-side, and the ASP is run on the server, I think you would have to post the page back to the server after the client runs the Javascript code.

In a nutshell, this is how I understand this scenario to work:

  1. The browser requests the ASP page from the server.
  2. The server runs the ASP code, and sends the resulting HTML page to the browser.
  3. The browser renders the HTML page, and now has a chance to run the Javascript code (and does so).
  4. Now that the Javascript code has run (and the Javascript variable has been assigned), something will have to be done to get that data back to the server so it can be “integrated” with the ASP code (i.e. post the page back to the server).

Does that make sense? (And for anyone more knowledgable in ASP than me, is this a fair understanding?)
LilShieste

For a newbie, Lil, you hit it on the head.

The most confusing part of web programming for new folks is getting used to the idea there are several different programs running on several different machines at once. I have one where we use a program on the server to dynamically emit code to the browser, where that code will run to communicate with another server, where other code we wrote is waiting for the message, which it’ll use as paramters to perform a lookup, then send a response back to the browser which in turn will call another client side control to make something else happen out another port to a thrid-party server/device, all within a single page view.

That’s 5 interacting hardware / software systems. Static HTML it ain’t, anymore.

Cool, thanks for the info LSLGuy. It’s comforting to know I’m on the right track. And I’m looking forward to working with systems like the one you described (I will be starting a new job soon that is ASP.NET-centric). :slight_smile:

Anyway, I hope this helps you out, enipla.
LilShieste

FYI, ASP & ASP.NET are as different as night and day. You can see how ASP.NET bears some vestigial family resemblance to ASP, but the whole point of ASP.NET is to get away (far, far away) from the ASP style of programming.

There’s still a lot of ASP code out there which needs maintenance and in many cases improvements. ASP.NET is the wave of the future in the MS web-world, but ASP is far from dead.

Don’t assume that just because you, or your coworkers, are gurus at one that you can make heads or tails out of the other.

Yes, I’ll agree that the frame needs to somehow post that value back to the server before any ASP page can access it… maybe by doing a form.submit to itself, or posting the value through a java applet… (A useful technique to learn when you’ve got javascript and ASP that you want talking to each other in certain ways, though it takes a little effort to set up and introduces yet another software system to the interactions.)

Whatever script the frame is talking to can then save the value, whether in a session variable, database, or a file on the server, so that it can be pulled out. Not terribly easy, but I thought I’d throw in a few constructive comments since everyone else is pretty much just saying ‘oh no you can’t do that.’

Oh, one other thought, it might not fit the situation or it might not… it’s comparatively easier to pass such a value from a frame back to the main window of the browser – writing it into a hidden variable or calling it as the parameter of a function. If you can manage to do that BEFORE your main frame calls its new .asp page, then the value you want can be passed as a parameter TO the .asp file, and will be available in request.form or request.querystring. That might help.

Yep, if you couldn’t tell I’m quite new to .asp as well.

This is a bit clearer now.

Problem is, an .htm calls both the .asp file and a .js file. The .js file sets the value in the frame that I’m after.

In debug ([Visual InterDev] I can see the value of NEWVALUE as I step through the .asp. But, I guess I’m already back in the client?

At the time of the call to the .asp file, the .htm file can’t access the var in the frame. I’ll try it again, but don’t think its set yet. Perhaps it’s a timing problem. I may be able to call an intermediate ‘blank’ htm, get the var I need and then pass the whole mess to .asp. It’s not very elegant, but it might work.

I hate trying to rebuild an existing application.

I hope that makes some sense. Thanks for your responses.

A final question… It doesn’t really matter that my .asp side is in vbscript instead of jscript. I’d still be having the same problem? In other words, it’s not a language incompatibility problem in my .asp file.

Thanks again, this is starting to make some sense.

No, language incompatibility is not the problem… running server-side and client-side script in the same language doesn’t get you anything except you presumably don’t make stupid syntax mistakes quite as often… :smiley:

The tough parts are the timing issue and the difference between server and client machines.

If (agree){
(Thanks}; everyone: It’s clearer now. + I ‘m Glad the vbscript asp verse & jscript asp != problem.} except for syntax.
End Sub
}
:smiley:

not jscript asp… at least I don’t believe you’re using that from your original question. CS jscript? (client-side.) can’t call it CSS for client-side scripting, because ‘cascading style sheets’ has dibs on that acronym :wink:

A common technique for this sort of problem is to put a hidden iFrame on your client page. Then, when you need to pass a javascript variable back to the server, you can either load it on the querystring or pass it in a hidden form through the frame. The variable is passed back to the server, which can process it and dynamically build an onload method to pass the variable back into your main page when the page loads in the hidden frame. I use this technique all the time for data that doesn’t change rapidly - like opening an expanded tree view, or populating a list box after someone selects an option.

For data that is constantly changing rapidly, this method is too slow, because there will be latency delays and you’re hitting your web server with a lot of page requests. In that case, you want to use something like a Java applet. However, I’ve been programming in Java for several years and I’ve grown to truly hate applets.

Thanks Sam.

The appication I’m modifying already has what it refers to as blank.htm. And I do make use of hidden iframes for a few things. Just thought there may be an easier way.

Well, really, a better way would have been to start from the ground up, but I just can’t do that at this point.

The good news is that I have lots and lots of existing code in this 'out of the box 'application that trys it’s best to do everything. I’ve got plenty of examples to work from.

On the other hand…

The bad news is that I have lots and lots of existing code in this 'out of the box application that trys it’s best to do everything for everyone. It just doesn’t do it very well. Tweek it here, and end up with a train wreck over there. Sort of the butterfly effect.