Solved

JavaScript calling database using ASP/VBScript

Posted on 2001-07-31
7
189 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 5

Expert Comment

by:raizon
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks for the points.  :-)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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/…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now