Welcome to WebmasterWorld Guest from 54.167.46.29

Forum Moderators: open

Message Too Old, No Replies

passing values of text fields to an iframe

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

New User

10+ Year Member

joined:Aug 25, 2003
posts:3
votes: 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.
cheers

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

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


Are the iframed document and the parent document on the same domain?
2:40 am on Aug 26, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 21, 2002
posts:977
votes: 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!";

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

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

New User

10+ Year Member

joined:Aug 25, 2003
posts:3
votes: 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)

New User

10+ Year Member

joined:Aug 25, 2003
posts:3
votes: 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.
3:20 am on Aug 26, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 21, 2002
posts:977
votes: 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.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members