Results 1 to 8 of 8

Thread: Mixing asp and Javascript

  1. #1

    Thread Starter
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667

    Mixing asp and Javascript

    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

    Code:
    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???


  2. #2
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    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.
    Have I helped you? Please Rate my posts.

  3. #3

    Thread Starter
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667
    thanks mate but i do not really wish to go down the reloading of the page route.

  4. #4
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    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?
    Have I helped you? Please Rate my posts.

  5. #5

    Thread Starter
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667
    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

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    CB, surely ASP can read query strings. Then it can be done that way.
    Have I helped you? Please Rate my posts.

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Sure, but they cannot mix. They can be executed serially, never in parallel.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width