Change the value of a textfield located on the parent page?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Change the value of a textfield located on the parent page?

Post by Sindarin »

I have a link in an iframe. When I click on it, I want it to write a value on a textfield called article_contentimage which is not located in the iframe but in the page holding that iframe. I tried,
<span style="cursor:pointer;" onclick="_parent.newpost.article_contentimage.value ='testing';"><img src="files/images/layout/delete.png" width="16" height="16" border="0" /> Remove Image</span> ]
but it doesn't work.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Change the value of a textfield located on the parent page?

Post by JAB Creations »

I haven't worked with iframes though it you are using JavaScript with two levels of frames you'll need to use _parent._parent..

Have you tried object detection to see if JavaScript can alert whether or not it sees the object you're trying to work with? I always alert things to see if they exist first...once they do then I write the corresponding JavaScript.
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Re: Change the value of a textfield located on the parent page?

Post by Sindarin »

Ah, I used parent.document.newpost.article_contentimage.value instead of _parent.newpost.article_contentimage.value and it works.
Post Reply