Forum Moderators: open

Message Too Old, No Replies

Submit form into window.opener

         

wavesurf

1:45 pm on Aug 21, 2006 (gmt 0)

10+ Year Member



Hi -

I have looked all over the internet for a solution to this, but I can't seem to find it, even though there seems to be a bunch of documents talking about it.

My script has a link that opens a new window that has a script with a form. When this form is submitted I want the action to happen in the original window.

According to the websites I have been visiting adding: onclick="this.form.target=window.opener;return true;" to the submit button should take care of this. However when I click the submit button, it opens a new window, and executes the action there instead.

I have tried with both FireFox and Internet Explorer 7. Any ideas why this doesn't work?

Thanks for all the help.

wavesurf

8:16 am on Aug 22, 2006 (gmt 0)

10+ Year Member



Actually I'm having more problems with this, since I'm trying to populate an input field with a calendar date by using a popup-window as well.

In my popup script I have links on all the dates that are laid out like this: <a href="javascript:window.opener.inputFieldName.value='yyyy-mm-dd';"> but I get an error saying that "window.opener.inputFieldName is null or not an object" in IE7 and "window.opener.inputFieldName has no property" in Firefox 1.5.

Anyone know why the window.opener doesn't seem to work as it should?

kaled

9:16 am on Aug 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Assigning the target property requires the name of a window not the window itself.

You could try something like

window.opener.name="opener728";
form.target="opener728";

however, I suspect the window.name property is read-only.

Alternatively, if you are certain that the opener already has a name then this might work

form.target=window.opener.name;

It's also possible that browsers assign unique names to otherwise unnamed windows, so the above would always work - I've never checked this.

Kaled.

wavesurf

11:31 am on Aug 22, 2006 (gmt 0)

10+ Year Member



Thanks a lot. Finally got the form in the popup to work, after experimenting with naming the windows.

However, I still have problems with changing an input fields value in the original window by clicking a link in the popup window.

Anyone?