[Javascript] how do you access a form element from another frame ?

DEV dev at qroute.net
Mon Dec 15 18:12:53 CST 2003


David,
This is the frame set structure I have.


 <FRAMESET rows=35,*>

  <FRAME name="frameWhite" marginWidth=0 marginHeight=0 src="white.asp"
noResize scrolling=no target="leftframe">

  <FRAMESET frameborder="0" cols=319,*>

   <FRAME name="frameBlue" marginWidth=0 marginHeight=0 src="blue.asp"
noResize scrolling=auto>
   <FRAME name="frameYellow" src="yellow.asp" scrolling=auto>

  </FRAMESET>


 </FRAMESET>


I still cannot get to the yellow.asp's textarea from a button in the
blue.asp.

Here is the situation again;

> >
> >
> > _______________________
> >
> >          ( frameGreen )
> > _______________________
> >                            |
> >                            |
> >                            |
> > ( frameBlue )        | ( frameYellow )
> >                            |
> >                            |
> >                            |
> >
> >
> > frameYellow has a form named frm1 and a textarea called textArea1
> >
> > how does a button on the frameBlue update the value in the textArea1
> >
> > I tried the following, all failed.
> >
> > onClick="top.frameYellow.document.frm1.textArea1.value='X'"
> >
> > onClick="top.frameYellow.window.document.frm1.textArea1.value='X'"
> >
> > onClick="parent.frameYellow.document.frm1.textArea1.value='X'"

What's onClick event to update yellow.asp textarea contents from the blue ?




----- Original Message ----- 
From: "David Lovering" <dlovering at gazos.com>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Friday, December 05, 2003 7:27 AM
Subject: Re: [Javascript] how do you access a form element from another
frame ?


> Generally, the following scheme will work across an assortment of common
> browsers (I tested it with IE6+, and the W3C specs support it).  I'm sure
> some of the syntax Nazis will get on my case, but here goes:
>
> var greenDoc = window.parent.top.document.frames['frameGreen'].document;
> var blueDoc = window.parent.top.document.frames['frameBlue'].document;
> var yellowDoc = window.parent.top.document.frames['frameYellow'].document;
> var redDoc = window.parent.top.document.frames['frameRed'].document.
>
> This of course assumes that you are within the contents of one of these
> forms (and not a remote child window), and that they are all spawned from
> the same top-level frameset.  Even more bizarre configurations are easy to
> manage with some slight tweaking.
>
> For example, if you were inside frameGreen, and you wanted to access field
> "myIndex" inside form "form1" which is contained within frameYellow,
> something like this might work:
>
> myIndexValue = yellowDoc.form1.myIndex.value;
>
> The only caveat is that some instances may require that you use an
> eval("stuff") instead of the core declarations I've included above.  The
> rule for requiring or not requiring this work-around is not absolutely
> consistant with the W3C spec (at least insofar as I've tested it with
IE6+).
> I'm sure someone more versed in the nuances of the "real" implementation
of
> the W3C specs will now step forward to enlighten me/us on the subject.
>
> Let me know if this works for you.
>
> -- Dave Lovering
>
> ----- Original Message ----- 
> From: "DEV" <dev at qroute.net>
> To: "[JavaScript List]" <javascript at LaTech.edu>
> Sent: Thursday, December 04, 2003 9:25 PM
> Subject: [Javascript] how do you access a form element from another frame
?
>
>
> > Here is the situation;
> >
> >
> > _______________________
> >
> >          ( frameGreen )
> > _______________________
> >                            |
> >                            |
> >                            |
> > ( frameBlue )        | ( frameYellow )
> >                            |
> >                            |
> >                            |
> > _______________________
> >
> >          ( frameRed )
> > _______________________
> >
> >
> > frameYellow has a form named frm1 and a textarea called textArea1
> >
> > how does a button on the frameBlue update the value in the textArea1
> >
> > I tried the following, all failed.
> >
> > onClick="top.frameYellow.document.frm1.textArea1.value='X'"
> >
> > onClick="top.frameYellow.window.document.frm1.textArea1.value='X'"
> >
> > onClick="parent.frameYellow.document.frm1.textArea1.value='X'"
> >
> >
> >
> >
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
> >
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list