[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Javascript popup, return to parent, close popup, run php program, passing a variable...

Posted on 2007-10-13
7
Medium Priority
?
5,066 Views
Last Modified: 2013-11-19
Not sure if this has been answered but I couldn't find it, although some questions were along the same lines in some way.  In a nutshell:

User chooses menu option
Open a popup number keypad
Get a login id and pass that to a php program
Check a mysql database for security level
If cleared, close the popup
Return to parent
Run the called php program, passing along user id.

It all worked great until I decided to make the number keypad a popup.  Having problems getting back to parent and finishing the task list.

Parent window is a menu.  Contains popup function:

   <SCRIPT LANGUAGE="JavaScript">
   function popUp(URL) {
   day = new Date();
   id = day.getTime();
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=245,height=355,left = 277,top = 122');");
   }
   </script>
   
When the user clicks menu item, I want to get a login id to check security access level for clearance.  The onclick pops up a number keypad whihc has been passed the name of the program to run if clearance is granted via mysql database as well as the calling program:

<div onclick="javascript:popUp('login.php?runprog=bomain.php&fromprog=index.php')">Back Office</div>


The login.php is a simple number keypad popup to allow user to enter a number.  When enter is pressed:

Calling:     <div Onclick="ChkAccess()">Enter</div>

function:
function ChkAccess()
{
   if (document.Login.Get_Logid.value != '0')
      window.location=''+ 'chkaccess.php?logid=' + document.Login.Get_Logid.value + '&runprog=<?php ECHO($liprogrun);?>'+ '&fromprog=<?php ECHO($lifromprog);?>' ;
}

ChkAccess.php snip that grants access:

        if ( $chksecreq <= $eseclvl ) {
           header("Location: $chkprogrun?logempid=$eempid");
           exit;
        } else {

This obviously opens the called program, passing along the user login code...

The problem is that I want the child-popup to return to the parent before opening the
called program.

I found the following JS on here and it sounded like it might do the trick, but alas, I was'nt sure where to put it and I wasn't at all sure of how to tell it to open the called program, passing along the user login code.  I presume my implementation is incorrect and/or the placement is incorrect, or I am simply way off base because I am a moron :) In over my head here. Can anyone show me the way?

Tried the following thinking it would return to parent and close the popup:

        if ( $chksecreq <= $eseclvl ) {
-->      <script>window.opener.location.reload(true);self.close();</script>
           header("Location: $chkprogrun?logempid=$eempid");
           exit;
        } else {...

Thanx a mil' for any help provided...
Owen
0
Comment
Question by:owenparker
  • 4
  • 3
7 Comments
 
LVL 16

Expert Comment

by:Kiran Paul VJ
ID: 20070891
try this

 if ( $chksecreq <= $eseclvl ) {
          echo("<html><head></head><body>");
          echo("<script>window.opener.location.reload(true);self.close();</script>");
          echo("</body></html>");          
          //header("Location: $chkprogrun?logempid=$eempid");
          exit;
        } else {...
0
 
LVL 16

Expert Comment

by:Kiran Paul VJ
ID: 20070897
and if you want to load  $chkprogrun?logempid=$eempid" in the parent try this

 if ( $chksecreq <= $eseclvl ) {
          echo("<html><head></head><body>");
          echo("<script>window.opener.location.href='".$chkprogrun?logempid=$eempid."'';self.close();</script>");
          echo("</body></html>");          

          exit;
        } else {...
0
 

Author Comment

by:owenparker
ID: 20071222
Sorry kiranvj, same result.  Click button, runs login.php in a popup, get login id, runs chkaccess.php, then opens called program (in this case bomain.php in popup window.  Problem seems to lie in the fact that i really need to go back 2 programs

index.php --> logn.php --> chkaccess.php --> back to index.php, close popup, run new program

any way to hop back twice or will it be necessary to do it via some sort of variable passing scema?
Thanx so much for the effort.  It looked like it had teeth :)
Owen
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:owenparker
ID: 20071252
Yes that's definitely the problem.  Chkaccess is dropping back to the popup whihc called it.  Is there a way to drop back to the original parent, or two children, so to speak?
0
 
LVL 16

Accepted Solution

by:
Kiran Paul VJ earned 2000 total points
ID: 20073426
If i get it correctly, this is what you want

index.php --> logn.php(Popup) --> Now user enters username and password and click login button-> Now close the popup and do login validation in chkaccess.php and reloads the index.php. Right??

if thats the case try some think like

function ChkAccess()
{
   if (document.Login.Get_Logid.value != '0')
     {
     
      window.opener.location=''+ 'chkaccess.php?logid=' + document.Login.Get_Logid.value + '&runprog=<?php ECHO($liprogrun);?>'+ '&fromprog=<?php ECHO($lifromprog);?>' ;
     self.close();
     }
}
0
 

Author Comment

by:owenparker
ID: 20078050
kiranvj, that was peerfect.  It sure does help to have to think things thru to explain to another.  Thanx for that and the perfect syntax and positioning for the code :)
Owen
0
 
LVL 16

Expert Comment

by:Kiran Paul VJ
ID: 20080299
thanks Owen, your comment was a great motivation.
thanks once again for the points and grade and glad i could help you.

cheers,
kiranvj
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses
Course of the Month19 days, 7 hours left to enroll

834 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