The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

existing window changes into php result, when need to stay the same

Hi there, i would appreciate it so much if somebody could please help me, i have been struggling on this problem for ages and i am not able to resolve it.

i have 1 html file (main page) this files has 4 forms, each form 1 after the other. the separte forms on the main page are used to post data to php files via text boxes and submit button.
for example i have a php file called availablewards, which takes the input from the html file and performs a query inregards to the input given and displays the result of the query.
the html file is like this
<form name ="ward" method= "post" action="availablewards.php" >
this form all so has a submit button that opens up the availablewards.php when clicked on opens the php file in separate window.
<input type="submit" value="Find ward" onclick="window.open('http://localhost/availableward.php')"

however the problem is the new window that opens does not show the query result, it shows blank. the result is diplayed in the main window, main window changes loction to availableward.php. i need for the main window to stay the same and for the query result to show in the newly opened window when the submit button is clicked on.

Sorry, Centauri, but that won't work. The action attribute requires an HTTP URI. You can't send an HTTP POST request to a JavaScript function. According to the spec,

User agent behavior for a value other than an HTTP URI is undefined.

If you want the action URI to open in a separate window, you can use the target attribute on the form, although that means you'll have to use a Transitional doctype.

Another option is to do something similar to what you're already doing, but append all the form's field names and values as query parameters at the end of the URI to window.open(). You'd have to use JavaScript to do that, of course, and your PHP script may have to be modified to accept GET requests instead of POSTs. It would also be better to have this behaviour in the onsubmit handler for the form, rather than the onclick handler for the button.

If you need to use POST and still want a pop-up window, you'll probably have to resort to an Ajax solution.