Jump to content

Recommended Posts

I want to have the results of a SQL query appear in a newly launched browser window.

As I am aware that this is a JS function, I have managed to accomplish that portion of the task by having the processing script become the new window.

action="processing.php" onclick="windowScript()"


function windowScript(){
 window.open("processing.php");
   }

 

but at this point, the $_POST data is NOT interacting.

I suspected that this is because the PHP processing script is no longer directly receiving the submitted data.

What is the best way to proceed?

Link to comment
https://forums.phpfreaks.com/topic/315052-query-results-in-a-new-window/
Share on other sites

If you just want a new window/tab without and special properties then simply add a target attribute to your form tag.

<form method="post" action="processing.php" target="_blank">

If you want to customize the popup window, add the target attribute and an onsubmit handler that open a window with the appropriate name.

<form method="post" action="processing.php" target="formResults" onsubmit="openWindow()">
function openWindow(){
  window.open('', 'formResults', 'width=800,height=600');
}

 

@ginerjm 

Quote

Do you want the results to show up as their own new window while the original window is still open at the same time? 

Yes, absolutely.

For example: a form with a drop-down of employee names that will provide data on a totally separate new window.

If data for a second employee was requested, a second new window would open to provide that data.

Theoretically, these windows could now be placed side by side for comparison and the main form would still be available and unchanged.

 

 

 

Edited by phppup
Forgot item

I'm getting closer, I suppose.

Using @kicken suggestion is giving me a separate window that processes and displays the desired information.

But apparently the target="xyz" forces the xyz-page to refresh with each click to submit.

As I mentioned to ginerjm,

Quote

....a second new window would open to provide that data.

Theoretically, these windows could now be placed side by side for comparison and the main form would still be available and unchanged.

so I want a new window [that would need to be physically closed by the user] with every individual click event.

Edited by phppup

I want the user to have the potential of clicking the same button a million times and having a million open windows on the screen.

As it stands now, the code will TARGET one window and refresh it a million times.

Please help me achieve MY goal by reading the previous posts.  With all due respect, I don't need to use AJAX or add buttons to close windows.

Have you done any thinking on how that might be done?

Using the word 'million' 3 times in your last post says to me that you are not really thinking a lot about this task you have defined.  If I were doing something like this for a user to open a few windows (< 1000000) I would use a session variable.  Maybe a couple of them.

Edited by ginerjm

OK I made a  mistake in this post and have corrected my test code.  If you use the blank value for the target attribute it will continue to open new windows for you  IF you manage to do the click from the original window and not one of the clones.

Edited by ginerjm
2 hours ago, phppup said:

But apparently the target="xyz" forces the xyz-page to refresh with each click to submit.

As I mentioned to ginerjm,

Then either use _blank, or generate a new unique target name for each submission.  If you generate new unique names, remember to use the name both in the window.open call and in the forms target attribute (update it in the submission handler).

@kicken I guess that's the road I'll have to take.

I was surprised to see that target= [which I suppose is really an HTML structure] was a solution to this problem. (I've never had occasion to use it until now)

I had originally attacked this issue from a PHP perspective, but after your info, I tried many variations of _blank to resolve this.  Some tests created duplicates of the form page, and others negated the new window and opened the data in a new tab (not what I wanted).

I did consider the possibility of adding a count++ so that every new window has a unique name but thought I'd see if there was a more simplified option 'built-in' that I wasn't uncovering online.

Thanks for your help and let me know if you have any other valuable ideas.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.