get a value from a popUp window

T

toufik toufik

Hi, I'm using the folowing javascript code to oprn a popUp window
msgWindow=window.open('','messageWindow', 'scrollbars=yes,width=300,
height=150');
msgWindow.document.open();
msgWindow.document.write(strHTML);
msgWindow.document.close();

In this window I've a form containing a text TXTNAME and a button that call
another function javascript popUpProcess()

How can I get the value of TXTNAME inside the function popUpProcess()?
I've tried message"Window.forms[0].TXTNAME .value" but it doesn't work.

Thanks.
 
M

Michael Winter

Hi, I'm using the folowing javascript code to oprn a popUp window
msgWindow=window.open('','messageWindow', 'scrollbars=yes,width=300,
height=150');
[snip]

How can I get the value of TXTNAME inside the function popUpProcess()?
I've tried message"Window.forms[0].TXTNAME .value" but it doesn't work.

"messageWindow" is the name of the window with regard to target
attributes. That is, target="messageWindow" on a link will open the page
in the popup window. msgWindow is what you want to use: it contains a
reference to the new window.

If you must use a popup window, you should allow users to resize it:

msgWindow = window.open('','messageWindow',
'scrollbars,resizable,width=300,height=150');

Then:

msgWindow.document.forms[0].TXTNAME.value

to reference the value.

Mike
 
T

toufik toufik

Thanks Mike,
But it doesn't work, I find that it works with this syntax
window.document.forms[0].TXTNAME .value

Now I can access the inputs of the original page

here is my case:
I've a page that contains a button, in the ONCLIC event I open the popUp
window, in the onClic event of the popup window I call a javascript function
where I assign the value entred in the popup to a text in the original page.

Thanks


Michael Winter said:
Hi, I'm using the folowing javascript code to oprn a popUp window
msgWindow=window.open('','messageWindow', 'scrollbars=yes,width=300,
height=150');
[snip]

How can I get the value of TXTNAME inside the function popUpProcess()?
I've tried message"Window.forms[0].TXTNAME .value" but it doesn't work.

"messageWindow" is the name of the window with regard to target
attributes. That is, target="messageWindow" on a link will open the page
in the popup window. msgWindow is what you want to use: it contains a
reference to the new window.

If you must use a popup window, you should allow users to resize it:

msgWindow = window.open('','messageWindow',
'scrollbars,resizable,width=300,height=150');

Then:

msgWindow.document.forms[0].TXTNAME.value

to reference the value.

Mike
 
M

Michael Winter

But it doesn't work, I find that it works with this syntax
window.document.forms[0].TXTNAME .value

[snip]

I assumed that you were trying to access the control, TXTNAME, that is in
the popup window from the opener window. In that case, you would need to
reference the popup like I demonstrated. As you're accessing the control
from within the same window, the expression below is sufficient.

document.forms[0].TXTNAME.value

My mistake.

Mike


Please don't top-post.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top