views:

49

answers:

1

Hi, I'm facing problem as of bellow,

  <form name="form_preview" id="form_preview" action="xxxx.php" method="POST" target="iframe_p">
 <input type="hidden" name="post_data" id="post_data" value="xxxxxxxx">
 </form>
    <script language="JavaScript">

        document.forms['form_preview'].submit();

    </script>

I'm having nested forms and trying to submit an inner form. This condition throws me an error like "document.forms['form_preview'] undefined"

please Help!

A: 

document.forms is somehow deprecated. Use document.getElementById('form_preview').submit(); instead. Also make sure the DOM is fully loaded before trying to manipulate its elements (window.onload).

Darin Dimitrov
hi, even document.getElementById('form_preview').submit(); did'nt work for me
Harshal
also tried window.onload=document.forms['form_preview'].submit();but no success :(
Harshal
try: `window.onload = function() { document.getElementById('form_preview').submit() };`
Darin Dimitrov