Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: forms in IFRAME


Message #1 by speedguru@m... on Mon, 20 May 2002 13:50:03
hi,

i'm trying to submit values from several forms present inside IFRAMEs & finally post it. 

I'm looking for a generic function that can fetch names of all elements.
My problem is, how can i access the forms without specifying the form names

document.frames[0].a.elements.length //this works

document.frames[0].forms[0].elements.length //but this won't 

how do i get this right ?


this is what i've got working so far -


main.html
----------------
<HTML>
<HEAD>
<TITLE></TITLE>
<script>
function show()
{
//alert(document.frames.length)
//alert(document.frames[0].a.elements.length);
framlen = document.frames.length
for (jcnt=0;jcnt<document.frames[0].a.elements.length;jcnt++)
{
	alert(document.frames[0].a.elements[jcnt].name);
}
//alert(document.frames[0].b.elements[0].id);

}

</script>
</HEAD>
<BODY>
<form>
Dring<br><iframe id="aframe" src="f1.html" scrolling='no' frameborder=0></iframe>
<br>Scrub<br><iframe id="bframe" src="f2.html" scrolling='no' frameborder=0></iframe>
<input type='button' value='submit' onclick='show()'>
</form>
</BODY>
</HTML>

f1.html
-----------

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<form name="a" id='a'>
<P><INPUT id=checkbox1 name=checkbox1 
type=checkbox>popsy</P>
<P><INPUT id=checkbox2 name=checkbox2 type=checkbox>croak</P>
</form>
</BODY>
</HTML>

f2.html
---------
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<form name="b" id='b'>
<P><INPUT id=checkbox2 name=checkbox2 type=checkbox>drove</P>
<P><INPUT id=checkbox3 name=checkbox3 type=checkbox>camal</P>
</form>
</BODY>
</HTML>

thanks for your time.....

  Return to Index