sridhar s
sridhar s

Reputation: 149

javascript submit 2 forms not working in chrome

I have 2 forms to be submitted on one submit click, to download 2 files.

This is downloading 2 files in Firefox, but downloads only 1 file in chrome.

I have edited and inserted full code as per the request.

Full code:

                <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>EXPORT INVOICE </title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <SCRIPT LANGUAGE="JavaScript">
      function runscript()
      {
        document.f1.submit();
        document.f2.submit();
      }
    </script>
    </head>

    <body>

    <form name="f1" method="post" action="export-tst-with-header.php" target="_blank">

    <table width="810" height="140" border="0" cellpadding="5" cellspacing="0" class="uniq" align="center">
      <tr class="uniq">
        <td width="363" valign="middle">
        <br>
        <span class="sty2">Enter to export From Invoice No.:</span>     <input type="text" size='10' maxlength='10' name="finv" onblur="showfrom(this.value);">
        &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <span class="sty2">To Invoice No:</span>&nbsp; <input type="text"  size='10' maxlength='10' name="tinv" onblur="showto(this.value);">
        </td>
      </tr>
      <tr class="uniq">
        <td width="363" valign="top"><div align="center"><br>
            <br>
            </form>

            <form name="f2" method="post" action="export-tst-with-header2.php" target="_blank">
            </form>

            <input type="button" value="Export" onClick="runscript();" />



    &nbsp;&nbsp;
    &nbsp;&nbsp;
          <a href='index.htm' target='_parent'><input name="close" type="button" value="Close !"></a>
        </div></td>
      </tr>
    </table>

    <br>
    </body>
    </html>

Upvotes: 1

Views: 3221

Answers (1)

Steven Moseley
Steven Moseley

Reputation: 16355

EDIT: Here is a test I ran, where I cleaned up a lot of your issues in HTML and JS. I found that this solution will, in fact, hit both URLs in Chrome.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>EXPORT INVOICE </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">
    function runscript() {
        document.forms.f1.submit();
        window.setTimeout(function() {
            document.forms.f2.submit();
        }, 500);
    }
</script>
</head>
<body>
    <table width="810" height="140" border="0" cellpadding="5" cellspacing="0" class="uniq" align="center">
        <tr class="uniq">
            <td width="363" valign="middle">
                <form name="f1" method="post" action="export-tst-with-header.php" target="_blank">
                    <br />
                    <span class="sty2">Enter to export From Invoice No.:</span>
                    <input type="text" size='10' maxlength='10' name="finv" onblur="showfrom(this.value);" />
                    &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <span class="sty2">To Invoice No:</span>&nbsp; 
                    <input type="text"  size='10' maxlength='10' name="tinv" onblur="showto(this.value);" />
                </form>
            </td>
        </tr>
        <tr class="uniq">
            <td width="363" valign="top">
                <div align="center">
                <br />
                <br />
                <form name="f2" method="post" action="export-tst-with-header2.php" target="_blank">
                </form>
                <input type="button" value="Export" onClick="runscript();" />
                &nbsp;&nbsp;
                &nbsp;&nbsp;
                <a href='index.htm' target='_parent'><input name="close" type="button" value="Close !"></a>
                </div>
            </td>
        </tr>
    </table>
    <br />
</body>
</html>

Upvotes: 2

Related Questions