PDA

Click to See Complete Forum and Search --> : Mixing asp and Javascript


Bombdrop
Apr 30th, 2004, 08:34 AM
Hi all and hats of to all you scripter i'm find it bloody hard.

i wish to assign a Javascript variable to my asp code .
I can get the data out but how do i get it in



var x=18;
<%
temp
%> = x;




not a good example but i wish temp stored in my ASP to be assigned to x a variable in my HTML javascript side. Can anyone help this idiot???

:wave: :thumb: :wave:

Acidic
Apr 30th, 2004, 08:43 AM
I don't think this can be done. You'd have to use query strings. eg:
the page that loads is:
www.a.com/b.html?p=123

then I think ASP can read that p=123.

Bombdrop
Apr 30th, 2004, 08:46 AM
thanks mate but i do not really wish to go down the reloading of the page route.

Acidic
Apr 30th, 2004, 10:12 AM
well ASP can only work at the server right? (I've never used ASP).

Which means that you are trying to read a JS variable set at the start of the page.

If this variable is a constant (always is 5.6) then you can just make the ASP variable also = 5.6
If the variable is one set on the previous page, then you've had to load a page anyway, so just make ASP read the query string.

I think you need to write a bit more what you're trying to do. where does the variable come from?

Bombdrop
Apr 30th, 2004, 10:14 AM
Thanks mate the information is dynamic i'm making a query string. So I'm looking at setting a cookie via my Jscript and then reading it into my ASP

CornedBee
Apr 30th, 2004, 02:22 PM
Not possible. The ASP is executed while the page is at the server. Then the result is sent to the client. There the JavaScript is executed.

You see, ASP and JavaScript are executed at completely different times and therefore cannot be mixed.

Acidic
Apr 30th, 2004, 03:55 PM
CB, surely ASP can read query strings. Then it can be done that way.

CornedBee
Apr 30th, 2004, 06:10 PM
Sure, but they cannot mix. They can be executed serially, never in parallel.