Solved

Whats the method to have a window opened and return that value to the current webpage in PHP

Posted on 2011-09-11
18
174 Views
Last Modified: 2012-05-12
We're trying to do something like in VB.  Open a look-up, select a row, and return the value selected to the parent window where the look-up window was selected.... but to no success.

Is this possible and can EE direct us on how to apply it to our PHP apps?
0
Comment
Question by:rayluvs
  • 10
  • 5
  • 3
18 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 36520294
The part about having a window opened may be the sticking point.  Why do you need a separate window?  Why not just bring in a script with require() and let the PHP in the script run the look-up you need?
0
 

Author Comment

by:rayluvs
ID: 36520684
We're not very fluent in PHP and the person we had, left.  So we have to work with this.

We're not familiar with require(), can you I've an example?
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 36521780
Good news!  All of the PHP functions are documented in the online man pages.  Example:
http://us2.php.net/manual/en/function.require.php

If you're not fluent in PHP, you will either have to get a PHP person (the fast and easy way to success) or become fluent in PHP (the slow and expensive way to success).  There are a lot of learning resources out there that can help with the latter.  This book is a great place to start.  Very readable with excellent examples.
http://www.sitepoint.com/books/phpmysql4/

PHP also has an introductory tutorial, that includes information about dealing with forms, which is how you get client input from the browser, so your action script can produce an appropriate response.
http://us2.php.net/tut.php

The things you would need to learn about in order to do what you describe are (1) Forms and the relationship to the action script, (2) Your data base (maybe MySQL) and how to query, retrieve and test for errors, (3) how to return the output to the client machine.  These are fairly well understood technologies with simple design patterns, but it is difficult to give you a demonstration script because we do not have your underlying data model.  But that said, the SitePoint book spells it all out.  Now in its fourth printing, it has been a part of my technical library since Version One.
0
 

Author Comment

by:rayluvs
ID: 36526458
We don't ant to become an expert on PHP, but E has helped us in many of our apps.  We'll look into the links.
0
 

Author Comment

by:rayluvs
ID: 36526581
Just reread your first response, and didn't quite answer your question on "Why do you need a separate window? ".

We want to replicate a process we do in VB; using look-up windows.  in other word, Window-1 has a customer field.  Next to the customer field there is a Binoculars icon. When user clicks on the Binocular, Window-2 appears with a list of Customers.  The user select the specific Customer in Window-2 and after selecting, it closes the window.  After WIndow-2 closes, the Customer selected appears in Customer field in WIndow-1.

Before continuing indulging in this process we want, two questions:

    1. In your experience, can this be done in PHP?
    2. Based on what we need, do you recommend a pop-up window should be used or
        is there another manner in getting what we want?

Please advice

0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 36526824
It can be done in PHP, but usually will be done in conjunction with AJAX.   A commonly used AJAX library is jQuery.  jQuery implements many of the best parts of JavaScript in an easy-to-use framework.
0
 

Author Comment

by:rayluvs
ID: 36526938
Its practical? Based on what we indicated, how would go about it?
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 36529026
Yes, it's practical.  If it were my application and I did not know much about PHP or AJAX, I would create some good screen shots of what I wanted to achieve (step-by-step illustrations) and I would hire a programmer who knew PHP and had a good portfolio showing his front-end development with jQuery.  The learning curve to become proficient in something like this is measured in years, and time is money.  So I would not try to do it myself.
0
 

Author Comment

by:rayluvs
ID: 36529231
Unfortunately, we have to do it ourselve.

Can you give us an example with at least 2 tables so we can have it as a guide?

Thank you.

0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 108

Expert Comment

by:Ray Paseur
ID: 36529259
No, I'm sorry.  I have a lot of paid work right now, and it would take me away from my clients to produce this.  I've given my best advice so I will sign off now.  

Here is a suggestion.  We have JavaScript and jQuery Zones here at EE.  Use the Request Attention link near the original question and ask a moderator to add your question to those zones.  There may be some other Expert Eyes who have an example they can show you.

Best regards, and best of luck with your project, ~Ray
0
 

Author Comment

by:rayluvs
ID: 36529442
Understood.
0
 
LVL 13

Expert Comment

by:haloexpertsexchange
ID: 36529502
you can interact with the parent window from the opened popup window using javascript.
What you do is use window.opener to refer to anything that is on the parent window.
It is not php but it is a fairly simple way to pass information back to the different window.
0
 

Author Comment

by:rayluvs
ID: 36529520
Wait... the 2 tables question at ID: 36529231 wasn't for this this question.

0
 

Author Comment

by:rayluvs
ID: 36529568
Hi haloexpertsexchange,  Can u give a simple example?  We would like to see the structure and from there on, research on the details of the tools in order to complete.
0
 
LVL 13

Accepted Solution

by:
haloexpertsexchange earned 300 total points
ID: 36529661
ok what I usually do is know the id of the field that you want the value to go to.
And then do something like this, no tools involved just plain javascript.
window.opener.document.getElementById("fieldid").value;
window.close();

Open in new window

Just so you know this will require that both the parent and the popup be in the same domain and both be in either http or https or you will get permissions issues.
But other than that it works rather well and is easy to implement.
0
 
LVL 13

Assisted Solution

by:haloexpertsexchange
haloexpertsexchange earned 300 total points
ID: 36529668
woops it should be window.opener.document.getElementById("fieldid").value=customer;
0
 

Author Comment

by:rayluvs
ID: 36529931
Ruano you very much!!  This gives an idea on where to concentrate.

Thanx
0
 

Author Closing Comment

by:rayluvs
ID: 36583072
Thanx
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

758 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

19 Experts available now in Live!

Get 1:1 Help Now