www.webdeveloper.com
Results 1 to 3 of 3

Thread: submit Two html forms with one javascript onclick event with Chrome

  1. #1
    Join Date
    Apr 2011
    Posts
    13

    submit Two html forms with one javascript onclick event with Chrome

    I have a web page with two forms, when I click the button on one of the forms, the onclick event goes to a javascript that emails the first form and then the second form. This is correct, this is the way I want this to work. It's simple, it's easy, it works!
    However, it only works in FireFox and Internet Explorer, it will not work in Google Chrome browser.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=windows-1250">
      <title></title>
      </head>
      <body>
    <form id="NameForm" method="post" action="mailto:yourFirstemail@email.com">
    Name: <input type="text" size="10" name="name"> <br />
    <input onclick=functionCaller() type="button" value="Submit Two Forms"> 
    </form>
    
    <form id="AddressForm" name="DComments" method="post" action="mailto:yourSecondemail@email.com">
    Address: <input type="text" size="10" name="address"> <br />
    </form>
    <script type="text/javascript">
    <!--
    function functionCaller()
    {
    document.getElementById('NameForm').submit();
    document.getElementById('AddressForm').submit();
    }
    -->
    </script>
    </body>
    </html>

  2. #2
    Join Date
    Aug 2009
    Location
    Sweden
    Posts
    1
    The first thing I notice is the call to the javascript function (the value for onclick) isn't even quoted...

    Modern browsers seem to be a lot less forgiving to quirky markup, so I'd suggest trying that... if all else fails validate the document to see what else is wrong.

    Hope this helps!

  3. #3
    Join Date
    Apr 2011
    Posts
    13

    still not working

    thanks, for noticing, I changed the line below but it still works fine in IE and FF but not Chrome. I will validate (again) and fix any other errors.

    Code:
    <input type="button" onclick="functionCaller()" value="Submit Two Forms">

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles