Posts Tagged Iframe Code

Accessing other frame data

In your main page you have an iframe. The iframe code is:

<input type=”text” value=”andy” name=”myname”>

To access the data from that iframe the syntax will be :

Formname.document.getElementsByName.(‘contaolname’)[0].value

So the code for the main file is:

<script>
function getvalue()
{
alert(frame1.document.getElementsByName(‘myname’)[0].value);
}
</script>
<iframe src=”form.php” name=”frame1″></iframe>

<input type=”button” value=”Get value” onclick=”getvalue()”>

, , , , , , ,

No Comments