How to reset a form target to iframe without reseting the form
Posted on 2008-11-04
<form action="" method="post" name="form_name" id="form_name" target="iframe_name">
The iframe tag:
<iframe name="iframe_name" id="iframe_name" width="0" height="0" scrolling="no" frameborder="0"></iframe>
var iframeSrc = webpage.html;
document.getElementById('iframe_name').width = '400'; //Re-sizes Iframe
document.getElementById('iframe_name').height = '275'; //Re-sizes Iframe
document.forms['form_name'].action = iframeSrc;
Everything works great.....until I hide the iframe (In case they want to make a change to the form inputs) and try to click the button a second time. On the second time around
the submit causes another window to open up. I can stop this from happening by forcing the page to reload when they close out of the iframe, however they then lose all entered data.
Any ideas on how to force it to target the iframe even after its run once and the iframe has been hidden.
P.S. I am hiding the iframe by setting the style.visibility to hidden so that the element still exists.