assign javascript variable value to VBScript server side variable

M

Matt

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!
 
R

Roji. P. Thomas

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
 
A

Anthony Judd

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top