Solved

JavaScript calling database using ASP/VBScript

Posted on 2001-07-31
7
193 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
[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
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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 informatio…
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 video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

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