Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:

Password:

Remember me

open a new 'popup style' window
Welcome, Guest. Please login or register.
November 23, 2008, 09:30:59 AM
11307 Posts in 1250 Topics by 501 Members
Latest Member: rosaline
Experts Round Table Network  |  Serverside Technology  |  PHP  |  open a new 'popup style' window « previous next »
Pages: [1]
Author Topic: open a new 'popup style' window  (Read 605 times)
Freddy

Offline Offline

Posts: 3


« on: October 27, 2007, 09:49:33 AM »

As this is the first forum I have ever posted in please be gentle.
The situation.
I am writing an application that allows the user to search for products in my database. If the search returns more than one match for the query I would like to launch a pop up style window that lists all the records found in a table so that they may select the appropriate product.
The Problem-How to launch the new window.
This pop up window would then pass the selection back to the main window and close. The closest function I have found is the openBrWindow(), however I do not know how to call it from with the If..then ..else block of my code. If its possible at all.
Any help will be greatly appreciated.
Logged
Esopo
Governing Council Member
*
Offline Offline

Posts: 74


WWW
« Reply #1 on: October 27, 2007, 03:45:02 PM »

Hi Freddy,

Welcome to ERT!

I'm thinking of two ways to go about this. One is to handle the new window with javascript (the window.open function):
http://www.quirksmode.org/js/popup.html

Then you can interact between windows:
http://www.quirksmode.org/js/croswin.html

You can close it with the .close( ) function.


The other way I think this would work is with an inside-popup: a block element in your HTML (usually a DIV) that is styled to look like a window and pops up on top of the rest of the page (set to absolute positioning). You can use AJAX to load the content into this block element.

For the popup, I personally would use something in the lines of:
Code:
<div id="MyPopup" class="HideMe">Here goes my popup content</div>
<a href="#" onClick="javascript:document.getElementById('MyPopup').className='MakeVisible'"> Open Popup </a>
Where the CSS class MakeVisible has the styling necessary to display the popup box (code to make it visible, absolute positioning, aesthetics).

For the AJAX part:
http://www.expertsrt.com/articles/VGR/ajax-demythified.html

I hope these put you in the right path.

Best regards,

Esopo.
Logged
Freddy

Offline Offline

Posts: 3


« Reply #2 on: October 27, 2007, 10:02:49 PM »

Thanks Esopo for the speedy reply.

I will look into your ideas further, they have certainly got me thinking about the solution in a different light.

A quick glance at the links and code you provided look promising.

Cheers,

Freddy.
Logged
GrandSchtroumpf
Mentor

Offline Offline

Posts: 409



« Reply #3 on: October 29, 2007, 12:16:11 PM »

Traditionally, search results are displayed in the same window (see Google, Wiki, Amazon, you name it).

Quote
If the search returns more than one match for the query I would like to launch a pop up style window that lists all the records found
What if the search returns only one match?  Do you want the product page to display in the main window?  If so, it's a little tricky to implement.  You will need to query the server twice.  The first time to determine if there is more than one match, the second time to take appropriate action (open new window or display the single product page).  You can use AJAX for that, but a proper public site should also work when javascript is disabled (if the site is an intranet webapp, then requiring javascript is fine).  If you don't use AJAX, you'll need to send the form to some target window.  If you don't want to loose the current page, that target needs to either be a new page or a frame (hidden?) that is inside your page.

Can you give more details?  In some web applications, some form fields have a selection tool to help the user select a valid value for the field (product account or other).  Is that what you are trying to achieve?
Logged
Freddy

Offline Offline

Posts: 3


« Reply #4 on: November 02, 2007, 06:17:29 AM »

Have been reading up on some of Esopo's suggestions.
Being new to web page creation still getting used to the idea of server side and client side programming as separate entities.

The concept of using getElementById() looks perfect for the job however I am struggling to implement it the correct way.
 
GrandSchtroump raises some good questions so I thought i would try to sell out what I am building and anything else that may help.
disregard if irrelevant, because I don't have the solution I can't make that call.

My programming experience is limited to a few years of part time study.
Mainly languages like C, C++, Delphi and Java(some time ago) along with some scripting using Awk & sed and now a little PHP.
Basically if you can write it using open source compilers.

The application I am writing is for use in an intranet environment at a small scale.  am developing a retail point of sale and management package to be used for running an automotive workshop(or similar). This is where I have been working for the last 20 or so years.

The page is constructed using frames (yes I have become aware during this project how this seems to divide web developers) sorry if your anti frames, forgive me and I'll promise not to do it again.
1. Left navigation frame - self explanatory what goes here.
2. Top header frame - Most pages requiring searches have the search fields loaded in the header frame.
3. Main frame. - The main page where the bulk of the entry forms or display of data tables load.

So here is a typical example which involves the use of the said pop up.

1. you (the customer) enter the premises to drop off car for service
2. I (the attendant) ask for some details to create the booking. lets say we start with your cars rego number (number plates, license plate)
3. your not sure of the whole rego only the first 3 letters "ABC' but you have been in before so it should be there.
3 I open the booking section enter the partial rego and search for its existence (this is where the pop up would do its thing) and display a selection of entries starting with 'ABC'
4 I select the correct entry from the pop up which closes and now loads the customer details into the main booking form in the main frame.
If no or an exact match occurs it closes and returns the found record or 0 so that I can select another option to add a new customer;

OK. so here is what I need.
1. when i click on the search button (can be either a type=button or submit )
 I need to get the data ('ABC') to the pop up to be used as the search criteria as the pop up form loads. Once its there everything else works.
I have worked out how to read the textfield writing a simple javascript which I can use to initialise a variable but when I try to pass it to the pop up nothing.
so here is what I am doing.(wrong!)

Code:
<input name="SubmitSearch" type="submit" id="SubmitSearch" value="Search" onClick="openPopupWindow('/customers/popup.php?searchID=myFunction(id)','ItemLookUp','scrollbars=yes,width=680,height=400' )" />

and any other variation I can think of.

Or could I have the pop up read the searchtext using the onload="" with something like windows.opener.?
Cheers,
Freddy
Logged
Pages: [1]
« previous next »
    Jump to: