In phpxperts yahoo group there was a thread about how to submit a form in a iframe outside the iframe I mean from parent window. I replied my idea using js but the iframe should be in same domain. The js code is like
[code language=”php”]window.top.myframename.document.myformname.submit();[/code]
let me give u whole code. make a new file named frame.html and write the bellow code in that file
[code language=”php”]
<form id="myformid" name="myformname" method="post" action="" target="_self" onSubmit="">
Name: <input type="text" size="20" name="name" value="" id="namefield" />
</form>
[/code]
and open a new file again and save in same dir with name index.html and write the bellow code in it
[code language=”php”]
< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Iframe form submit from outside</title>
</head>
<body>
<div id="infodivid"></div>
<iframe src ="frame.html" width="auto" height="40px" frameborder="0" id="myframeid" name="myframename">
</iframe>
<p><input onClick="submitiframeform(); return false;" type="button" name="submit" value="Submit" /></p>
<script type="text/javascript">
function submitiframeform(){
window.top.myframename.document.myformname.submit();
}
</script>
</body>
</html>
[/code]
now open the index.html in browser and click the submit button and see the form is getting submitted. I think If you just check the code then I don’t need to explain ‘what is why’.
thanks