Solved

JavaScript calling database using ASP/VBScript

Posted on 2001-07-31
7
191 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

832 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