form-pop up

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
In php, is there any way to submit button(in a form) makes window


<form id="form1" name="form1" method="post" action="vehicle.php">
    <input name="submit" type="submit" id="submit" value="submit" />

This goes to only action page. (vehicle.php)
I wanna  pop-up the page(vehicle.php) and use data from index page.
Also when i close the pop up page, I wanna use data in index what was
selected in pop-up page(vehicle.php)

Is it possible? Thx!

Re: form-pop up

kirke wrote:

Quoted text here. Click to load it


This has little to do with PHP. It is just a HTML thing.
Just add a target to your form and it will pop-up in a new window.
(If you need to address that window from javascript, use the name you just  
gave it in your form.)

<form action="vehicle.php" method="POST" target="myNewWindow">

Erwin Moller

Re: form-pop up

wow! thx! that's exactly what i want!

can i do one more question?

Thus, i can pop-up the window.
and there's also drop-down box. and we need submit button.
However, when i click the submit button (in pop-up window), i want to
close it and its action page is index.php(previous page)
which commend is needed to do this?
Thx! again!

Erwin Moller wrote:
Quoted text here. Click to load it

Re: form-pop up

kirke wrote:

Quoted text here. Click to load it

good. :-)
Glad to be of help.

Quoted text here. Click to load it


The easiest way to do this is by making the target of the form in the popup  
a new script that:
1) processes your posting. (DB-update or something)
So you do NOT let your original page do the processing.
2) will only output this:
  // process your posting of the dropdown

  <script type="text/javascript">
   // optionally refresh the original page

   // close this popupwindow

But this might get you into trouble because javascript is now closing a  
window that is NOT created by JavaScript.
Some browsers will ask the user for permission to close the window, which is  
an annoyance in your case. Test it.

You can solve this by letting Javascript open the popup in the first place.
If JavaScript opened the page, the browser will let JavaScript close it  
without a warning.

This has little to do with PHP, but I'll give you an example. If you need  
more, just go to the right place: comp.lang.javascript

How to let Javascript open a new window?

1) Replace your submitbutton with something like this:
<input type="button" value="makepopup" onClick="doPopup();">

and add a function somewhere on your first page:
<script type="text/javascript">
 funtion doPopup(){
   // make a new window with the name MyNewWindow
   var myPopup ="blank.html","MyNewWindow");
  // Post the form


You'll have to provide an empty page named blank.html.
Also name your form by adding name="bla", and use that name in the  

Warning1: I didn't test this, but the idea works.
Warning2: This will completely fail if the visitor has no Javascript  
If this is the case, then you cannot close a popup window, no matter what.

Erwin Moller

Site Timeline