Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > assign javascript variable value to VBScript server side variable

Reply
Thread Tools

assign javascript variable value to VBScript server side variable

 
 
Matt
Guest
Posts: n/a
 
      09-25-2004
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!


 
Reply With Quote
 
 
 
 
Roji. P. Thomas
Guest
Posts: n/a
 
      09-25-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!
>
>



 
Reply With Quote
 
 
 
 
Anthony Judd
Guest
Posts: n/a
 
      09-25-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run server-side vbscript subroutine from client-side javascript victor.buga@gmail.com Javascript 2 01-22-2007 04:05 PM
Making the same button do client side javascript and server side vbscript? COHENMARVIN ASP .Net 2 10-20-2005 01:13 AM
Syntax for linking to javascript/vbscript on the server side/client side Eitan ASP .Net 2 06-04-2005 11:06 AM
server-side vbscript call with javascript client-side David Shorthouse ASP General 2 02-03-2005 07:39 PM
How can Server-Side variable'value be given to Client-Side variable by program Jack ASP General 3 01-29-2004 01:09 AM



Advertisments