Click to See Complete Forum and Search --> : Form inside iframe


MMMike
06-24-2003, 04:04 AM
I have two pages. One with an iframe in the body:

<iframe name=ifr1 width=100 height=100 src=ifr1.html></iframe>

and ifr1.html with a form:

<form name=f1 id=f1>
<input type="Hidden" name="hid" value="hid">
</form>
In the main (first) file I want to access form f1 elements:
document.ifr1.document.f1 and
document.ifr1.document.forms[0] and
document.ifr1.document.forms['f1'] and
frames.ifr1.document.f1 gives me undefined.

How can I access form elements inside a iframe?

JHL
06-24-2003, 04:16 AM
this work for me in ie5.5:

ifr1.document.f1.hid

MMMike
06-24-2003, 04:30 AM
I've tried that:

ifr1.document.f1.hid

For ifr1.document I get [object], but ifr1.document.f1 or ifr1.document.forms[0] gives undefined too, as if there were no forms. Just can't get it...

Browser is IE 6.0

JHL
06-24-2003, 04:32 AM
i've tired

alert(ifr1.document.f1);

and it give me [object].

Sorry, can't seems to solve your problem. Maybe some other people here can.

MMMike
06-24-2003, 04:51 AM
Thanks to JHL. Maybe I've missed something else in my code files. Are there any requirements?

JHL
06-24-2003, 08:22 PM
this is the code i used:

test1.html

<html>
<head>
<script type='text/javascript'>
function testing()
{
alert(ifr1.document.f1);
}
</script>
</head>
<body>
<iframe name="ifr1" width=100 height=100 src='test2.html'></iframe>
<input type="button" value="test" onclick="testing()">
</body>
</html>


test2.html

<html>
<head>
</head>
<body>
<form name=f1 id=f1>
<input type="Hidden" name="hid" value="hid">
</form>
</body>
</html>