Page 1 of 1

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

Posted: Thu Nov 13, 2008 6:23 am
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.

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

Posted: Thu Nov 13, 2008 10:59 pm
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.

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

Posted: Fri Nov 14, 2008 9:04 am
by Sindarin
Ah, I used parent.document.newpost.article_contentimage.value instead of _parent.newpost.article_contentimage.value and it works.