Go Premium for a chance to win a PS4. Enter to Win

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 796
  • Last Modified:

Passing Javascript variable to VBScript

Does anyone know of a way to set a vbscript variable equal to a javascript variable without reloading the page? I can't figure out how to do that...thanks in advance!
2 Solutions
animated405Author Commented:

Maybe a little context would be nice...

What I would like to do is validate a code a user would enter through a form and display an alert box if the code isn't in my db, without submitting the form.

really simple just change the tags as treat as the same variable

<script language=VBScript>
ZvonkoSystems architectCommented:
The lookup for code in db is not gona work in browser.
You have to submit the form to do the lookup on server side.
If you provide all codes to browser side, then is the user also able to lookup the code in the page source :-)
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

animated405Author Commented:

Thanks, that's great except for I'm going to be using some logic in the asp that connects to the database and I notice that because it's contained within the script tags like that it shows on when you view the source. I don't want even a procedure name or connection variable to be present for anyone to see. Thoughts?

thanks again
animated405Author Commented:

Sorry nevermind, I don't know what I was thinking that I could use a connection to the db that way...but that's good to know for future reference passing the variable around like that
ZvonkoSystems architectCommented:
For that is Experts Exchange: To talk about it.
It is gone fast that one do not see the forest because of the trees :-)

Thanks for the points.

I was just browsing through the solutions and saw this one, and thought I would comment on it.

There is actually a way. Have a hidden iframe:

<iframe style="display:none;" src=somepage.asp name=aspFrame></iframe>

The iframe should look something like this:

dim varName
if varName<>"" then
   response.write("<script>alert('The variable is called "+varName+"');</script>");
end if

<form action=somepage.asp method=post>
<input type=hidden name=fieldName>

And when you want to send the data, do this:

varName="Some value";

I haven't actually tested it but it should work.
animated405Author Commented:

That's an intersting technique, I'll have to play around with that as well. thanks

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now