473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

targeting main window from popup

Hello there,

I'm running a script that opens a popup window (which is basically a
form with checkboxes and a submit button). When I click the submit
button I want to run a PHP script and target the result to main page (I
mean, update the parent page).

My popup form looks like this:

<form name="form1" action="run.php" method="get" target="???">
<form fields....>
<input type="submit"....>
</form>

What should I give in ???? for target?

Any help is appreciated.

TIA
Hemanth

Oct 28 '05 #1
5 2823
> What should I give in ???? for target?

window.onload = function() {
f = document.getElementById('myform');
f.target = window.opener;
}

should work. If not, since I am assuming that the form just updates
values somewhere that will affect how the main window is displayed, you
may just use the popup as its own target, and after it is submitted
output:
window.onload = function() {
window.opener.reload();
window.close(); // optional
}

Oct 28 '05 #2
VK
> targeting main window from popup

Unless you're working for intranet you should re-think your model using
virtual div/iframe popup.

Your current approach will not work for about 50% of your current web
visitors and about 80% by the end of this year.

See for details:
<http://groups.google.com/group/comp.lang.javascript?start=60&hl=en>

Oct 28 '05 #3
VK wrote:
targeting main window from popup
Unless you're working for intranet you should re-think your model using
virtual div/iframe popup.

Your current approach will not work for about 50% of your current web
visitors and about 80% by the end of this year.


Where exactly do you got these numbers and dates from?
See for details:
<http://groups.google.com/group/comp.lang.javascript?start=60&hl=en>


Most certainly not from there.
PointedEars
Oct 28 '05 #4
Joshie Surber wrote:
What should I give in ???? for target?
window.onload = function() {
f = document.getElementById('myform');
f.target = window.opener;
}


......Thanks for your reply. How should I call this function in the
form??
should work. If not, since I am assuming that the form just updates
values somewhere that will affect how the main window is displayed, you
may just use the popup as its own target, and after it is submitted
output:
window.onload = function() {
window.opener.reload();
window.close(); // optional
}


......I tried something like this before. This what I did:

function update_parent()
{
window.opener.reload();
window.close();
}

<form name="myform" action="run.php" method="get"
onSubmit="javascript:update_parent()">

This runs the PHP script but displays the results in popup page (not in
opener and didn't close the popup window as expected). I'm using
Mozilla and IE browsers. I close the popup window manually and have to
"refresh" the main window to see the results in main window.
function update_parent2(url)
{
window.opener.location.href=url;
window.close();
}
<form name="myform" action="run.php" method="get"
onSubmit="javascript:update_parent2('run.php')">

The javascript works fine but doesn't actually run the PHP script as
expected. I mean, the "update_parent2" replaces the main window with
specified url and closes the popup window but the user (checkbox) input
in popup form is not being used.

Any more pointers would be helpful.

TIA
Hemanth

Oct 28 '05 #5
Hemanth wrote:
Joshie Surber wrote:
> What should I give in ???? for target?
window.onload = function() {
f = document.getElementById('myform');
var f = document.forms['myform'];

is both sufficient and downwards compatible. One probably want to add

if (f)
{ f.target = window.opener; }

*if* that approach would work (which it does not).
}


.....Thanks for your reply. How should I call this function in the
form??


You don't, since it does not work this way. The `target' attribute value
is of type string, not an object reference that window.opener returns.
What may work is

if (f && window.opener && !window.opener.closed)
{
window.opener.name = "foo";
f.target = "foo";
}
[...] should work.


No, it definitely should not and will not.
function update_parent()
{
window.opener.reload();
window.close();
}
window.opener.location.reload(), which is probably what you were
looking for, only reloads the opener document. It does not transmit
information newly input by the user.
<form name="myform" action="run.php" method="get"
onSubmit="javascript:update_parent()">
Proprietary `javascript:' URIs do not belong into attribute values for
intrinsic event handlers (as recent discussions have shown, they seldom
belong anywhere). So `javascript:' is but a label here, used only by
the MS script engine. Remove the labels and, for user agents who support
it, properly declare the default scripting language via a `meta' child
element of the `head' element:

<meta http-equiv="Content-Script-Type" content="text/javascript">
This runs the PHP script but displays the results in popup page (not in
opener
BAD. B0rken as designed.
and didn't close the popup window as expected).
Because there is no such intrinsic method as window.opener.reload() in any
AOM (Application Object Model) I know. You received a script runtime error
when trying to call it, but you either overlooked or ignored that.
function update_parent2(url)
{
window.opener.location.href=url;
window.close();
}
<form name="myform" action="run.php" method="get"
onSubmit="javascript:update_parent2('run.php')">
That will not transmit any new data either. You probably notice that
pure fantasy syntax such as this seldom returns a viable result. Get
yourself some decent documentations on HTML, JS, AOM/DOM (there are
plenty on the Net, for free) and develop according to them. See
<http://jibbering.com/faq/>.

<FAQENTRY>

- In section 3.2, the FAQ still refers to

http://devedge.netscape.com/library/...1.3/reference/

which is dead since almost a year:
<http://www.mozillazine.org/talkback.html?article=5381>

It should point to a mirror like

<http://devedge-temp.mozilla.org/library/manuals/2000/javascript/1.3/reference/>

- Not mentioned in the FAQ, there was also a documentation on JavaScript 1.5
available on DevEdge, which is now hosted at the Mozilla Foundation
website:

<http://developer.mozilla.org/en/docs/JavaScript>

- General information on JavaScript, the ECMAScript 3 Final Specification
and previous editions can be found at

<http://www.mozilla.org/js/>

and

<http://www.mozilla.org/js/language/>

- W3C DOM Level 1 HTML has been obsoleted by W3C DOM Level 2 HTML (see:
"Status of this document" section), yet the FAQ refers to the former's
ECMAScript Language Binding section. It should refer to

<http://www.w3.org/TR/DOM-Level-2-HTML/ecma-script-binding.html>

instead.

- The FAQ does not contain any reference to any W3C DOM Level 3
specification:

<http://www.w3.org/DOM/>

</FAQENTRY>
The javascript works fine but doesn't actually run the PHP script as
expected. I mean, the "update_parent2" replaces the main window with
specified url and closes the popup window but the user (checkbox) input
in popup form is not being used.
As I wrote, it's just BAD.
Any more pointers would be helpful.


[x] done
HTH

PointedEars
Oct 28 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Keith | last post by:
This is for an Intranet application before I go any further. I have a form which requires calendar dates, cities etc. to be input. This is not a problem, but when a user clicks to input a date...
1
by: William Starr Moake | last post by:
The browser-based WYSIWYG editor I'm developing has a popup window with a form that generates table code from user input (width, border, cols, rows, bgcolor.) But the user has to copy-paste the...
7
by: Jens Peter Hansen | last post by:
Hi From my main window I open a series of popup (one close - next opens) in a mockup for a registration proces. From the last popup, I want to click a buttom, so the popup closes and the URL in...
3
by: MEM | last post by:
Hello, I'd like to refresh the main or top most browser window from a child window. Specifically, child popup A is opened by a main browser window then child popup B is opened from within child...
1
by: Piotr | last post by:
I have popup window (window.open) where I put any value in input field. After submit I wan to to return to the main window and get value from popup window. How to close popup window and return to...
5
by: Jay | last post by:
I have a situation where the user clicks on a button in a DataGrid to launch a popup window via javascript. In the popup window the user does some things that result in changes to the underlying...
1
by: inbamca | last post by:
Hi, Functionality is like when pressing 'CTRL+click' on drop down list in the main jsp page, a popup window appears with a list box contains all the values of the drop down clicked on the main page....
3
by: Jimmy | last post by:
It is also possible for popup window to call function in main window by using the opener property. Will "opener.someFunctionInMain(param1, param2)" in the popup window work? It's possible for...
3
by: DrKen | last post by:
I need to have a user be able to click a link or button that brings up a popup window. When the user selects an item from the drop down list on the popup window (should I require only a click of...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.