Generic Parent/Child Communications

E

EoRaptor013

I have 40 or 50 inputs scattered among many pages that all need the
ability to open a popup which allows the user to navigate a file
directory structure, locate a specific file, and return the fully
qualified file name to the parent window input. All the 40 or 50 inputs
have unique IDs. Given any one input ID, I have everything working
perfectly: the parent form opens the popup using
window.open("FileFinder.aspx?dir=" + UserRootDirectory + "&InPutID=" +
IdCodeInOnClick);

Popup talks back to parent using window.opener.document...

Like I said, give me the input field ID and I can make everything work
every time... but it makes NO sense to write 40 or 50 functions, one
for each unique input field. I tried using

window.opener.document.forms[0].getElementByID(InPutID).value

but I keep getting an error message about something requiring an
object. Is there a way to accomplish this? Also, since I'm new to
JavaScript (and web programming generally), is there a good tool for
debugging JavaScript intended for IE?

Thanks.
Randy
 
I

Ian Collins

EoRaptor013 said:
I have 40 or 50 inputs scattered among many pages that all need the
ability to open a popup which allows the user to navigate a file
directory structure, locate a specific file, and return the fully
qualified file name to the parent window input. All the 40 or 50 inputs
have unique IDs. Given any one input ID, I have everything working
perfectly: the parent form opens the popup using
window.open("FileFinder.aspx?dir=" + UserRootDirectory + "&InPutID=" +
IdCodeInOnClick);

Popup talks back to parent using window.opener.document...

Like I said, give me the input field ID and I can make everything work
every time... but it makes NO sense to write 40 or 50 functions, one
for each unique input field. I tried using

window.opener.document.forms[0].getElementByID(InPutID).value
getElementById (note spelling) is a document method, it can't be used on
elements.
 
R

Randy Webb

EoRaptor013 said the following on 5/3/2006 12:17 AM:
I have 40 or 50 inputs scattered among many pages that all need the
ability to open a popup which allows the user to navigate a file
directory structure, locate a specific file, and return the fully
qualified file name to the parent window input. All the 40 or 50 inputs
have unique IDs. Given any one input ID, I have everything working
perfectly: the parent form opens the popup using
window.open("FileFinder.aspx?dir=" + UserRootDirectory + "&InPutID=" +
IdCodeInOnClick);

Popup talks back to parent using window.opener.document...

Like I said, give me the input field ID and I can make everything work
every time... but it makes NO sense to write 40 or 50 functions, one
for each unique input field. I tried using

window.opener.document.forms[0].getElementByID(InPutID).value

window.opener.document.getElementById(InPutID).value

Or:

window.opener.document.forms.elements['elementName'].value;

forms don't have a getElementById (It is Id, not ID though).
but I keep getting an error message about something requiring an
object.

Object expected? That is because it was hunting a getElementByID instead
of getElementById (even though forms don't have a gEBI)
Is there a way to accomplish this?

See above.
Also, since I'm new to JavaScript (and web programming generally),
is there a good tool for debugging JavaScript intended for IE?

Experience reading those cryptic error messages. After you read about
the third million of them, they start making half sense. Use Firefox and
its JS Console and your learning curve will be a lot less bumpy.
Thanks.
Randy

Makes me feel like I am talking to myself. As long as I don't answer
myself it's ok though :)
 
E

EoRaptor013

Well, I'm still missing something. On the call to window.open I store
the return field ID in a hidden input on the child aspx. Then, on the
call back, I use:

var sRtnField = hfReturnField.value;
window.opener.document.forms.elements[sRtnField].value = "Client
Folders" + NewClientDir;

And here's the error message I get:

window.opener.document.forms.elements has no properties

Can you see what I'm doing wrong?
Thanks.
(When you talk to yourself it's called praying. When you answer
yourself it's called schizophrenia.)
 
E

EoRaptor013

Thanks to both Randy Webb and Ian Collins.

I tried using -- and properly capializing -- getElementById correctly
(always helps) and it worked! You folks just made my life SO much
easier.

Randy
 
R

RobG

EoRaptor013 said on 03/05/2006 3:09 PM AEST:
Well, I'm still missing something. On the call to window.open I store
the return field ID in a hidden input on the child aspx. Then, on the
call back, I use:

var sRtnField = hfReturnField.value;
window.opener.document.forms.elements[sRtnField].value = "Client
Folders" + NewClientDir;

And here's the error message I get:

window.opener.document.forms.elements has no properties

"forms" is a collection, you have to specify *which* form, either using
its name or index in the forms collection. If you only have one form in
the page:


window.opener.document.forms[0].elements...


If you have multiple forms, it is better to use the form's name, say:

window.opener.document.forms['aForm'].elements...


If you have HTML like: <form name="aForm" ...>
 

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,774
Messages
2,569,596
Members
45,144
Latest member
KetoBaseReviews
Top