Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TextArea access within a frame

Status
Not open for further replies.

aldend123

Technical User
Feb 21, 2005
7
0
0
US
______________________
| | here is the javascript code,
| | in frame1
|_____________________|
| |
| | in frame2, i have a textarea
|_____________________|

I can't figure out how to access the textarea to get and set text.
I tried

var p = parent.document.getElementById("targetframe") p.getElementByName("targetboxname").value="fdsafdsfas";

but that doesnt work. however it works to set the textarea when they are in the same frame (removing the getelement for the frame of course)

so the problem lies in accessing the textarea in frame2 from frame1.
 
Assuming the textarea has an ID of "myTextArea", I'd use:

Code:
parent.frames['frame2'].document.getElementById('myTextarea')

or possibly even:

Code:
parent.frame2.document.getElementById('myTextarea')

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
awsome, thanks
however now i have a new problem
getElementsByName() wont access a named textbox
getElementById() will though

ie

var p = document.getElementsByName("sourceboxname");
alert(p.type) = alert box says undefined

var p = document.getElementById("sourceboxid");
alert(p.type) = works, returns textarea

for various reasons, the target/source textboxes must both be named, and refered to by name, not id. so why wont getElementsByName() work?
and incase you were wondering, this textbox is within the same frame the jscript code is in, so no need to impliment the code you gave me.
 
im trying to create a simple way for my boss to edit a webpage in which our business is only granted online web access (no FTP etc) and to edit each HTML doc, we must go through a textarea element on the webpage. I want to make a way for her to simply type her username, login, and what she wants to appear on our news page, have it wrapped in all the html/css i need, and have it placed in the html doc at the right position. sure its the long way to get the job done, but because of some awsome management, the setup really cant be changed.


anyways long story short, i cant change the attributes of the textarea, and by default, it only has a name.
 
incase you were wondering, this textbox is within the same frame the jscript code is in

So nothing like the diagram you first showed us with the textarea in frame2, and the code in frame1, then?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top