Chris Pietschmann

husband, father, hacker, entrepreneur, futurist, innovator, autodidact

NAVIGATION - SEARCH

JavaScript: How to get value from nested form in iframe?

Here is an example of how to get a value from a nested form in an iframe. It works in IE6, but not Netscape 7.1.

PageOne.htm
<html>
<head>
<script language='JavaScript'>

 function Search() {
  alert(document.frames("PageTwo").document.forms("Members").elements("Search").value);
 }

</script>
</head>
<body>
<input type='button' value='Search' onclick='Search();'>
<iframe name='PageTwo' src="PageTwo.htm" width='100%' height='100'>
</body>
</html>

PageTwo.htm
<html>
<body>
<form name='Members'>
    <input type='text' name='Search' value='Chris'>
</form>
</body>
</html>

blog comments powered by Disqus