Solved

Carrying values from a form to a pop up box with Javascript

Posted on 2002-03-26
9
220 Views
Last Modified: 2013-11-28
I want to have a login area on the homepage and once users fill in their username and password I want to use a pop up box on the screen to tell them the results.  

The problem: I can't get seem to carry the values from the 2 fields, useranme & password, from the homepage to the pop up box using Javascipt.

I can use Javacript to launch the pop up window but not carry the values across.

Any ideas?

One thing I don't want to do is use a querystring or something that exposes values because I don't want to show passwords.

Derek.

0
Comment
Question by:dgwest
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 2

Expert Comment

by:DanielBlais
ID: 6896819
You may call another page.  If the login and password are correct, store them in a session variables.  And them open the pop-up in javascript.  In the pop-up, verify the session variables are ok and display the data.
0
 
LVL 3

Accepted Solution

by:
barryfandango earned 50 total points
ID: 6896844
dgwest,

Please elaboriate on what you mean by "the results."  What is it you wish to display in this popup window?

I'm assuming your problem is that you want to pop up an ASP page that will verify the user's login and password.  How about this:

1. user inputs login/pw on main ASP page, hits Submit
2. main page reloads, passing itself the login/pw in the form of Form Data.
3. an ASP script at the top of the main page checks for form data, validates the login/password, and generates a javascript routine to pop up the results.

i.e.

<%
'check to see if form was submitted
if len(request.form("login"))>0 then
  ...(script to check l/p)...
  if validated = true then
    message = "You have been successfully logged in."
  else
    message = "Login or Password incorrect."
  end if
  response.write("<script language=""javascript"">")
  ...(etc. - generate a script to pop up a window displaying the "message" variable.)...
end if
%>

Hope this helps.
0
 
LVL 7

Expert Comment

by:weesiong
ID: 6896848
dqwest,

Javascript popup a xx.asp

in the xx.asp validation the password, and response.redirect goto other page --> Password Correct/Password Error

In this case, when in the last page, use canot see the querystring. and you can pop up a page to disable the header for the browser, more safe.

Best Regards,
Wee Siong
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:dgwest
ID: 6896941
barryfandango,

I like what you've proposed.  Let me try it.  I don't know how to fire the javascript popup window though.  
0
 

Expert Comment

by:taftman
ID: 6896996
javascript popup window:

function openWin(){
window.open("yourPage.html","NameOfPage","width=550,height=550,screenX=300,screenY=90")
}
0
 

Expert Comment

by:taftman
ID: 6896999
or do you mean an "alert box"?

alert("stuff in here");

or displaying variables:

alert(foo);
0
 
LVL 3

Expert Comment

by:barryfandango
ID: 6897008
dgwest,

you could create two HTML files, one with the confirmation message and one with the denial message.

modify the above script to read like:

if validated = true then
   message = "yes.html"
else
   message = "no.html"
end if

Then create your new window:

response.write("<script language=""javascript"">")
response.write("window.open(" & message & ",""theWindow"",""height=200,width=200,menubar=no,directories=no,scrollbars=no,toolbar=no, resizable=no"")")
response.write("</script>")

Within yes.html and no.html, you might want to include a button that fires "window.close()".
0
 

Author Comment

by:dgwest
ID: 6897013
barryfandango,

I like what you've proposed.  Let me try it.  I don't know how to fire the javascript popup window though.  
0
 
LVL 2

Expert Comment

by:manihopever
ID: 6898915
Dear dqwest,

i have just coded a sample, make few changes and flexible things to work.

login.asp
----------
<script language=javascript>
  function showPopup(){
    pop= window.open("validate.asp","validate","width=100, height=200")
    document.frm.target = "pop"
    document.frm.submit()        
  }
</script>
<form name=frm onsubmit="">
<input type=text name=login>
<input type=password name=password>
<a href="javascript:void showPopup()">login</a>
</form>

validate.asp
------------
<%
strlogin = Request.Form("login")
strPwd   = Request.Form("password")
if strlogin="dqwest" and strpwd="pass" then
  response.write "welcome dqwest"
else
  response.write "illegal entry, please try again."  
end if  
%>
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Filter Question 8 83
Error viewing ASP page 12 164
Issues with Insert statement 12 26
Accurate Analytics (Not Google) 2 41
Read about how to choose the best possible content marketing agency to suit your needs. Content marketing has become an integral part of running a successful tech business, so it is wise to be informed.
Read about the 3 stages of the buyer's journey: awareness, consideration, and decision.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

777 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