Need Some help with submitting one form to multiple sources

Discussion in 'Programming' started by chrisj383, Jul 14, 2012.

  1. #1
    Hey i need some help in submitting one form to 3 different sources, i've got it working to submit to 2 but i can't get it to work to submit it to 3.

    Here's the code i'm using

    First Form
    <div id="div_form"
     name="div_form">
                <form id="form1" name="form1"
    action="http://ebizac.com/ar/optin.php" method="post">
    <input type="hidden" name="action" value="addlead">
    <input type="hidden" name="member" value="3222">
    <input type="hidden" name="auto" value="13206">
    <input type="hidden" name="delauto" value="">
    <input type="hidden" name="thankyou" value="http://www.google.co.uk">
    <input type="hidden" name="resubsetting" value="Y">
    Email: <input type="text" name="email" /><br /><br />
                  <div class="myButton">&nbsp;
                    <input name="Submit" value="" onclick="document.form2.form3.email.value = document.form1.email.value; document.form2.form3.submit();
                    
                     setTimeout('document.form1.submit()',8000);"
     type="button" />
                  </div>
                </form>
                </div>
    Code (markup):
    Second Form
    <form id="form2" name="form2" accept-charset="utf-8"
     action="http://ebizac.com/ar/optin.php" method="post" target="iframe" style="display: none;">
     <input type="hidden" name="action" value="addlead">
    <input type="hidden" name="member" value="3222">
    <input type="hidden" name="auto" value="13092">
     <input name="email" type="text" /> 
     </form>
    Code (markup):
    Third Form
    <form id="form3" name="form3" accept-charset="utf-8"
     action="http://ebizac.com/ar/optin.php" method="post" target="iframe" style="display: none;">
     <input type="hidden" name="action" value="addlead">
    <input type="hidden" name="member" value="3222">
    <input type="hidden" name="auto" value="13089">
     <input name="email" type="text" /> 
     </form>
    Code (markup):
    Could anyone help me in solving this issue?

    Thanks,
    Chris
     
    chrisj383, Jul 14, 2012 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    two are iframes? and the first isn't?
     
    EricBruggema, Jul 15, 2012 IP
  3. chrisj383

    chrisj383 Well-Known Member

    Messages:
    754
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    130
    #3
    yes the other 2 are iframes and the first is'nt
     
    chrisj383, Aug 1, 2012 IP
  4. webfella

    webfella Member

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #4
    You can do it with jQuery by cloning each form and appending to a temporary iframe and then calling submit on the iframe form
     
    webfella, Aug 2, 2012 IP
  5. webfella

    webfella Member

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #5
    Took a while for me to find some code but here it is in jQuery.

    
    var frmContents = $('#form1').clone(); 
    $('#iframe').contents().find('html').html(frmContents);
    $('#iframe').contents().find('form').submit();";
    
    Code (markup):
    You can do this for any number of forms on the same page, and just put a hidden iframe on the page.
    
    <iframe id="iframe" style="display:none"></iframe>
    
    Code (markup):
     
    webfella, Aug 2, 2012 IP