By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,482 Members | 3,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,482 IT Pros & Developers. It's quick & easy.

assign javascript variable value to VBScript server side variable

P: n/a
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!
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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" <ma*******@hotmail.com> wrote in message
news:Ob**************@tk2msftngp13.phx.gbl...
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!

Jul 19 '05 #2

P: n/a
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" <ma*******@hotmail.com> wrote in message
news:Ob**************@tk2msftngp13.phx.gbl...
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!

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.