Welcome to WebmasterWorld Guest from 54.167.29.212

Forum Moderators: open

Message Too Old, No Replies

passing values of text fields to an iframe

     

drhardrive

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

10+ Year Member



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

tedster

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

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



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

Purple Martin

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

WebmasterWorld Senior Member 10+ Year Member



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!";

drhardrive

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

10+ Year Member



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

drhardrive

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

10+ Year Member



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)

WebmasterWorld Senior Member 10+ Year Member



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month