homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

passing values of text fields to an iframe

 12:05 am on Aug 26, 2003 (gmt 0)

Hi WebMasters/Mistresses,
before i go anymore bald than i already am would someone please help me out on this problem:
i want to set a value of a textfield in an iframe using the values sent from the parent window. how do i go about doing this?
i have a javascript function that says:
document.frames['framename'].itemtochange.value="change for the love of god!";

but apparently this doesnt work
any help on this would be appreciated.
i have a feeling that because its an iframe you cant reference and change its content from the main screen. but i hope im wrong.



 12:50 am on Aug 26, 2003 (gmt 0)

Are the iframed document and the parent document on the same domain?

Purple Martin

 2:40 am on Aug 26, 2003 (gmt 0)

Try these (make sure you've set the id attribute of the iframe element):

Modern browsers:
document.getElementById("iFrameID").itemtochange.value = "change for the love of god!";

document.all.iFrameID.itemtochange.value = "change for the love of god!";


 3:02 am on Aug 26, 2003 (gmt 0)

cheers purple will try it later but i think i tried the getbyid thingy and it didnt work. I think because its on a different page it wont set the attributes. gonna have to think of another way of doing it. thanks for your help gents but if anyone has done this and it has worked for them please tell me so i can save me some programming time. thanks again


 3:11 am on Aug 26, 2003 (gmt 0)

tedster they are both pages i have created. the iframe is not sourced anywhere. i have created all the pages including the iframe... i think thats what you meant by same domain. in anycase i dont think the domain of the page matters as long as you can reference it the way it needs to be referenced.

Purple Martin

 3:20 am on Aug 26, 2003 (gmt 0)

The getElementById thing should work. Note that the spelling of the word getElementById is case-sensitive. If you get one letter wrong (upper or lower case) it won't work. It's very common for people to accidentally use an upper case D at the end which causes much frustration. It's even misspelt in some reference books.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved