assign javascript variable value to VBScript server side variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt

    assign javascript variable value to VBScript server side variable

    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

    #2
    Re: assign javascript variable value to VBScript server side variable

    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



    "Matt" <mattloude@hotm ail.com> wrote in message
    news:ObAoDRsoEH A.3988@tk2msftn gp13.phx.gbl...[color=blue]
    > If I assign VBScript server side variable a to javascript variable x, it[/color]
    is[color=blue]
    > 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!
    >
    >[/color]


    Comment

    • Anthony Judd

      #3
      Re: assign javascript variable value to VBScript server side variable

      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" <mattloude@hotm ail.com> wrote in message
      news:ObAoDRsoEH A.3988@tk2msftn gp13.phx.gbl...[color=blue]
      > If I assign VBScript server side variable a to javascript variable x, it[/color]
      is[color=blue]
      > 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!
      >
      >[/color]


      Comment

      Working...