assign javascript variable value to VBScript server side variable

Discussion in 'ASP General' started by Matt, Sep 25, 2004.

  1. Matt

    Matt Guest

    If I assign VBScript server side variable a to javascript variable x, it is
    fine.
    <%
    Dim a, b
    a = 10
    %>
    var x = <%= a %>;
    alert(x);

    But if I do the other way around, then it has 500 error. any ideas??

    <% b %> = x;


    thanks!
     
    Matt, Sep 25, 2004
    #1
    1. Advertising

  2. Obviously, You cannot assign a client side varaible to a server side
    variable.

    OK, and as you think, you CANNOT assign a server side varaible to a client
    side variable too.

    When you say

    var x = <%= a %>;

    by the time the Client side script is ready to process, it sees a real value
    like

    var x = 5;

    And this not a good practice anyway, because, you will end up in

    var x = ;
    if the <%= a %> happened to be NULL

    --
    Roji. P. Thomas
    Net Asset Management
    https://www.netassetmanagement.com


    "Matt" <> wrote in message
    news:...
    > If I assign VBScript server side variable a to javascript variable x, it

    is
    > fine.
    > <%
    > Dim a, b
    > a = 10
    > %>
    > var x = <%= a %>;
    > alert(x);
    >
    > But if I do the other way around, then it has 500 error. any ideas??
    >
    > <% b %> = x;
    >
    >
    > thanks!
    >
    >
     
    Roji. P. Thomas, Sep 25, 2004
    #2
    1. Advertising

  3. Matt

    Anthony Judd Guest

    Off the top of my head!!!!!

    There are a couple of options available:

    1) assign the a client side variable to a form element and post the form.
    2) generate a link with the variable listed among its querystrings, requires
    the link to be clicked.

    I would do some error checking though to make sure you are passing valid
    data back and forward.

    Hope this gives you a couple of ideas..
    AJ



    "Matt" <> wrote in message
    news:...
    > If I assign VBScript server side variable a to javascript variable x, it

    is
    > fine.
    > <%
    > Dim a, b
    > a = 10
    > %>
    > var x = <%= a %>;
    > alert(x);
    >
    > But if I do the other way around, then it has 500 error. any ideas??
    >
    > <% b %> = x;
    >
    >
    > thanks!
    >
    >
     
    Anthony Judd, Sep 25, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eitan
    Replies:
    2
    Views:
    550
    Eitan
    Jun 4, 2005
  2. COHENMARVIN
    Replies:
    2
    Views:
    897
    Jason Kester
    Oct 20, 2005
  3. Jack
    Replies:
    3
    Views:
    240
  4. David Shorthouse

    server-side vbscript call with javascript client-side

    David Shorthouse, Feb 2, 2005, in forum: ASP General
    Replies:
    2
    Views:
    378
    Mark Schupp
    Feb 3, 2005
  5. Replies:
    2
    Views:
    293
Loading...

Share This Page