|
Posted by Erwin Moller on 10/11/06 08:31
kirke wrote:
> wow! thx! that's exactly what i want!
>
good. :-)
Glad to be of help.
> can i do one more question?
sure.
>
> 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!
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
?>
<html>
<head>
<script type="text/javascript">
// optionally refresh the original page
opener.location.reload(true);
// close this popupwindow
self.close();
</script>
</head>
</html>
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 = window.open("blank.html","MyNewWindow");
// Post the form
document.forms["yourformnamehere"].submit();
}
</script>
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
documnt.forms["bla"].submit();
Warning1: I didn't test this, but the idea works.
Warning2: This will completely fail if the visitor has no Javascript
enabled.
If this is the case, then you cannot close a popup window, no matter what.
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|