Solved

JavaScript calling database using ASP/VBScript

Posted on 2001-07-31
7
190 Views
Last Modified: 2008-02-01
I want to use an onSubmit to check a database, and open a pop-up to collect a password if necessary.

Opening the pop-up is obviously easy- but how do I get the javaScript function to execute the VBScript and connect to the database.

Basically the flow is as follows:

1.  User enters a userName
2.  On clicking the Submit button the javaScript function checks the database.
3.  If the userName belongs to a registered user, the function opens a pop-up prompting for the associated password.
4.  On Submitting the password in the pop-up, the function then checks the password against the userName in the database.
5.  If the password is a match the javaScript then redirects to the next page.
0
Comment
Question by:russoffl
  • 4
  • 3
7 Comments
 
LVL 1

Author Comment

by:russoffl
ID: 6337914
I guess as an alternative, once Page 1 has collected the userName, and the form (Submit) hands the data to Page 2, I could use an onLoad method to do the userName lookup.

The issue - or problem still remains - How do I execute VBScript/ASP code from within the javaScript.
0
 
LVL 5

Accepted Solution

by:
raizon earned 50 total points
ID: 6337916
You have the server look for the form to be filled.  If it is then you connect to the database and check the password and username.

<%

If NOT IsEmpty(Request.Form("UserName")) And IsEmpty(Request.Form("Password")) Then

'Connect to database

Else

'Redirect to fill out all fields

End If


%>
0
 
LVL 1

Author Comment

by:russoffl
ID: 6338131
The application lends itself better to a javaScript method of validation.  Most javaScript validation script use cgi - I need to stick to ASP/VBScript.  So the problem is allowing the JavaScript to execute the ASP code.
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
LVL 5

Expert Comment

by:raizon
ID: 6338195
Understood.

The code I posted doesn't necessarily validate the form but rather is a way of testing to see if the form was posted then executing the ASP code if returned True.

Since the JavaScript is running on the client side there is no way for it to execute the ASP code until the control has been passed back to the server such as posting the form.
0
 
LVL 1

Author Comment

by:russoffl
ID: 6339215
I understand that you cannot get client side to execute server side scripts without recalling the page, or calling another page.  I was hoping that there was a way for JavaScript to execute server side / database selects.

Since a pop-up is a page, I guess I could get the JavaScript to execute server side scripts by opening a new window/pop-up, passing a value from the original page to the pop-up.  The pop-up's ASP/VBScripts could then do the database call.  JavaScript in the pop-up could then pass the "verified" or "failed" back to JavaScript in the parent window.

Just have to figure the JavaScript code out.

0
 
LVL 5

Expert Comment

by:raizon
ID: 6341174
Try this

<body onload="self.opener.document.location='main.asp?success=<%=  strSuccess %>'; window.close()">

Then in the ASP set the variable strSuccess to either verified or failed depending on the output.

0
 
LVL 5

Expert Comment

by:raizon
ID: 6377685
thanks for the points.  :-)
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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