I have an akward problem where I've got two iframes on one page, and when one iframe loads I want it to communicate with an object of the other iframe.

The code looks like this:
<IFRAME NAME=1 ID=1 SRC=\"frame1.php\"> </IFRAME>


<IFRAME NAME=2 ID=2 SRC=\"frame2.php\"></IFRAME>


frame1.php contains a form called mainform2 which contains an input box called input. The goal is to change the value of input.

Since iframe2 is the one that is going to be loaded to alter the object in Iframe1 I came up with this code:

parent.frames[1].document.forms.mainform2.input.value = '$newvalue';
(This line is supposed to tell the browser to out of iframe2, go into the main page, then into iframe1 to change the input object found in iframe1's form.)


The problem is this doesn't work. Any suggestions?