change text field from within an iframe

S

sid derra

hi

i am trying to change the value of a text field on my page dynamically,
every time an iframe loads.

#==========

the code where the text field is looks like this:

<form name="test_form">
<input type="text" name="test_field" value="initialized" />
</form>

#==========

the iframe is embedded like this:

<iframe src="iframe_content.php" name="page" />

#==========

and the iframe_content.php site does this, before it gets to the <html> tag:

<script language="javascript">
document.parent.test_form.test_field.value = 'page X loaded';
</script>

#==========

i also have tried "frames[0]" and "parent" instead of "top". no success.
what i want it to do is, as soon as he iframe_content.php site loads, the
text field (test_field) should show "page X loaded", where "X" is a value
that's being dynamically set.
the problem is, that it doesn't do that. any ideas on what i would have to
change?

thanks a lot in advance!
sid
 
E

Erwin Moller

sid said:
hi

i am trying to change the value of a text field on my page dynamically,
every time an iframe loads.

#==========

the code where the text field is looks like this:

<form name="test_form">
<input type="text" name="test_field" value="initialized" />
</form>

#==========

the iframe is embedded like this:

<iframe src="iframe_content.php" name="page" />

#==========

and the iframe_content.php site does this, before it gets to the <html>
tag:

<script language="javascript">
document.parent.test_form.test_field.value = 'page X loaded';
</script>

#==========

i also have tried "frames[0]" and "parent" instead of "top". no success.

I guess you made a typo here because it still says parent.

did you try:
parent.frames["page"].document.forms["test_form"].test_field.value= ...

Regards,
Erwin Moller
 
S

sid derra

"Erwin Moller"
sid said:
i also have tried "frames[0]" and "parent" instead of "top". no success.

I guess you made a typo here because it still says parent.

in fact, i did ;-)
did you try:
parent.frames["page"].document.forms["test_form"].test_field.value= ...

i did now, no luck though unfortunately. the html source now says

<script language="javascript">
parent.frames["page"].document.forms["test_form"].test_field.value = 'page X
loaded';
Regards,
Erwin Moller

still - thank you!
 
E

Erwin Moller

sid said:
"Erwin Moller"
sid said:
i also have tried "frames[0]" and "parent" instead of "top". no success.

I guess you made a typo here because it still says parent.

in fact, i did ;-)
did you try:
parent.frames["page"].document.forms["test_form"].test_field.value= ...

i did now, no luck though unfortunately. the html source now says

<script language="javascript">
parent.frames["page"].document.forms["test_form"].test_field.value = 'page
X loaded';
Regards,
Erwin Moller

still - thank you!

Ok, do you get any securityalerts?
Check this by visiting your website with firefox and open the
javascript-output.

Are you maybe trying to set something in a different domain?
I mean, does the html in both pages (the original and the one in the Iframe)
come from the same domain???

Regards,
Erwin Moller
 
S

sid derra

"Erwin Moller"
sid said:
"Erwin Moller"
sid derra wrote:
i also have tried "frames[0]" and "parent" instead of "top". no
success.

I guess you made a typo here because it still says parent.

in fact, i did ;-)
did you try:
parent.frames["page"].document.forms["test_form"].test_field.value= ...

i did now, no luck though unfortunately. the html source now says

<script language="javascript">
parent.frames["page"].document.forms["test_form"].test_field.value =
'page
X loaded';
Regards,
Erwin Moller

still - thank you!

Ok, do you get any securityalerts?
Check this by visiting your website with firefox and open the
javascript-output.

Are you maybe trying to set something in a different domain?
I mean, does the html in both pages (the original and the one in the
Iframe)
come from the same domain???

Regards,
Erwin Moller

thanks erwin (do you speak german?)

yes, both the code fragments come from the same domain - in fact, they are
all generated by the same php file.
i'll check out the firefox security console...

sid
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,261
Messages
2,571,041
Members
48,769
Latest member
Clifft

Latest Threads

Top