Click to See Complete Forum and Search --> : updating parent window element


periscope
07-21-2003, 10:02 PM
I have a child window, from which one can make a selection. I wish that value to update an INPUT field in the parent window. The parent INPUT field has an ID argument which the child is aware of.

How is this done? Can this be done? I do not seem to be able to find any document. instruction to do this.

Any hints?

pyro
07-21-2003, 10:35 PM
Try something like this:

window.opener.document.formname.inputname.value = "yourvalue";

where formname is the name of the form on the parent window, and inputname is the name of the input area in that form...

periscope
07-22-2003, 08:30 AM
Ok, I have set up a situation to produce this and realize something about the name attribute in the form tag. I have read that this is Netscape only, is this still true?

pyro
07-22-2003, 08:32 AM
No, that will work cross-browser...

periscope
07-22-2003, 08:53 AM
Nice that things have moved on!

No I am getting no script errors, but also no parent window update. This is the button HTML in the child window:

<INPUT TYPE="submit" NAME="choose" VALUE="Choose" CLASS="we_ed_button" onMouseDown="window.opener.document.uploader.packet2.value='/user_manual/sections/test2';">

Do you see any obvious errors?

Thank you for your help btw. I am coding in PLSQL and these branches out into javascript are dynamically created, and my working knowledge of javascript is fairly much beginner. I would spend a lot more time reading but I have a deadline, so your help is very much appreciated.

pyro
07-22-2003, 09:01 AM
That code worked fine for me:

<html>
<head>
<script type="text/javascript">
newwin = window.open();
newwin.document.write('<INPUT TYPE="submit" NAME="choose" VALUE="Choose" CLASS="we_ed_button" onMouseDown="window.opener.document.uploader.packet2.value=\\'/user_manual/sections/test2\\';">');
</script>
</head>
<body>
<form name="uploader">
<input type="text" name="packet2">
</form>
</body>
</html>

periscope
07-22-2003, 09:24 AM
That is encouraging! However I get a missing ')' script error when I try to display your example page.
Also, is it crucial that the text INPUT tag to be written to has NO value="" attribute? Could that be my problem?
Additionally, both these windows are popups, if that makes any difference.

pyro
07-22-2003, 09:28 AM
Originally posted by periscope
Additionally, both these windows are popups, if that makes any difference. Yeah, it might... We're going to need to know how these windows are related to each other... ie. are they both children of one parent, or is the second a child of the first?

periscope
07-22-2003, 09:31 AM
The first window I have not mentioned yet.
This window can create a popup as a child window, which in turn
launches a second popup as it's child, so we have three
windows.

periscope
07-22-2003, 09:32 AM
The third window fills in the input in the second window.

pyro
07-22-2003, 09:37 AM
Then the above code should work fine... Are you getting an error message and if so, what is it?

periscope
07-22-2003, 09:40 AM
Line: 5
Char: 182
Error: Expected ')'
Code: 0
URL: etc.etc.etc.

pyro
07-22-2003, 09:46 AM
Crap. I just noticed the forums messed up my post. I bet it will work better now... ;)

periscope
07-22-2003, 09:58 AM
Um... does this mean you have a new version?

Btw, seen your web pages, interesting!
What we are building here is a web presence application using Oracle where sites are editable by non-tech people, in any language you like ( interface too ), with the ability to contain any functionality you wish really. Large project, four years so far. Very satisfying from a coders point of view.

pyro
07-22-2003, 10:02 AM
Yeah, I edited my above post (with the code), so it should work now.

I'm currently working on something that sounds close to what you are doing. Mine is done in javascript (so it's IE5.5+ only, unfortunatly) and PHP... It's getting there. I've worked on it pretty sporatically, so it's taking longer than it should. ;)

periscope
07-22-2003, 10:12 AM
Ahah!! So it does. I see the '/'s are crucial!

Your direction is not the first, indeed it is the more cost effective way to go as a developer, Oracle licences and
Sun machines not being cheap!
However, I like the reliability of the set up, and the fact that
we can host hundreds of sites on one machine, all using the
same general core code and objects. It's the generality
that takes the time to develop, and of course making everything easily editable by any 'dumb' ;) executive.
All online of course, no client install ( IE5.5 + for wysiwyg ),
kinda 'update you site from an internet cafe on the beach in
the Bahamas!'.

Thanks for the help and the exchange. Afraid our site is sadly
out of date ( typical isn't it, customers always come first! ), but go to www.etellus.com to get a vague idea. Ignore the customer list, it's out of date badtime!

pyro
07-22-2003, 10:16 AM
Very nice site, asthetically...

periscope
07-22-2003, 10:55 AM
Rats and damn. Now I get an invalid character error. Probably the inclusion of the \

The only difference between our examples is that you used document.write whereas I am just including the html line in a normal html page. Can this cause that error???

periscope
07-22-2003, 11:14 AM
My mistake!!!

Actually, the problem I have is that there are more than one 'packet2' elements, for non-related uploader reasons.
Life could be tough if I have to make this a uniquely named tag. Can one access a named array so I can pick the tag I want from the commenly named tags???

pyro
07-22-2003, 11:21 AM
I've never tried, but this may work:

window.opener.document.uploader.packet2[0].value="..."

[edit - Just remembered that you said it had an ID, so you could do this:

window.opener.document.getElementById("theid").value="..."[/edit]

periscope
07-22-2003, 11:33 AM
Success!!!!!!! with getElementById()

Thanks everso!! I'd buy you a beer if you were local ;)

Regards,

Ian.

pyro
07-22-2003, 11:39 AM
And if I was 21? ;)

periscope
07-22-2003, 12:03 PM
:) Ah yes, forgot, I did read your profile, hey it's legal in England! You make me feel old! ;) Thanks for helping a dodering old man - he-he. Anyway, it's what goes on in ya head that matters!