Solved

Passing Javascript variable to VBScript

Posted on 2004-03-26
8
767 Views
Last Modified: 2012-06-27

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!
0
Comment
Question by:animated405
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 

Author Comment

by:animated405
ID: 10689235

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.

thanks
0
 
LVL 31

Assisted Solution

by:GwynforWeb
GwynforWeb earned 100 total points
ID: 10689308
really simple just change the tags as treat as the same variable
<script>
x=10
</script>

<script language=VBScript>
y=x
document.write(y)
</script>
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 25 total points
ID: 10690563
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 :-)
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

Author Comment

by:animated405
ID: 10690653

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
0
 

Author Comment

by:animated405
ID: 10690681

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
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10690763
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.

0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 10692519
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
varName=request.form("fieldName")
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>
</form>

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

varName="Some value";
window.frames["aspFrame"].document.forms[0].fieldName.value=varName;
window.frames["aspFrame"].document.forms[0].submit();

I haven't actually tested it but it should work.
0
 

Author Comment

by:animated405
ID: 10701075

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

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question