Results 1 to 3 of 3

Thread: Submitting two forms.

  1. #1
    Join Date
    Jan 2014

    Submitting two forms.


    I have a html file with a form system two process orders.

    The first form ("form") collects the personal data of the customer and submits it to an email address for me to know her/his identity and contact details so as to reply or deliver the items.

    The second one ("form-order"), immediately after the first form in the code, collects the operation and total information to redirect it to a php file that processes it to the bank.

    The first form displays a series of required fields that must be filled to allow the processing of it and the second form.

    No processing of operation information without a previous sending of personal information to the email address.

    The code is as following:

     <form name="form" action="http://cgi.the web site.com/FormMail.pl" method="post">
            <input type="hidden" value="968" name="order"/> 
            <input type="hidden" name="redirect"/> 
            <input type="hidden" value="online@the web site. com" name="recipient"/> 
            <input type="hidden" value="Purchase" name="subject"/> 
            <input name="required" type="hidden" value="Name,Address, E-Mail"/>
              <h2>Personal Identification</h2>
                <div id="fa"><p>Full Name<input name="Name" type="text" id="Name"/></p></div>
           <div id="fa">
              <h2>Contact Details</h2>
                <div id="fab"><p>Address<input name="Address" type="text" id="Address"/></p></div>
                <div id="fac"><p>E-Mail<input name="E-Mail" type="text" id="E-Mail"/></p></div>
              <div id="fza"><input onclick="Javascript:aceptar()" type="button" value="SUBMIT" name="Submit"/></div>
              <div id="fzb"><input type="reset" class="Button" value="ERASE"/></div>
          <form name="form-order" action="control.php" method=post target=_blank">
            <input type="hidden" name="operation"/> 
            <input type="hidden" name="Total"/> 
    In the former version of this code, for its processing by asp, the collecting of data and information was different and the submission of "form" triggered the processing of "form-order".

    Now, an adaptation to php has modified everything.

    The javascript: document.form-order.submit();

    The problem is that the content of "form" is not submitted obviously.

    We can add: document.form.submit();

    But in this case the two forms are submitted, so the second form ("form-order") is processed whether the required fields in "form" are filled out or not. You are redirected to control.php and then to the bank page, and get another window with a message from "form", asking for the proper filling of the fields, resulting in two independent forms.

    There must be a way to process the first form and then, if the required fields are filled, trigger the function document.form-order.submit(); to get the second for submitted.

    I have tried different options with no result at all.

    My knowledge of js is not so good.

    I would appreciate some help on this issue.

    Thanks very much.

  2. #2
    Join Date
    May 2006
    Somewhere behind your screen
    <!doctype html>
    <meta charset="utf-8" />
    body{color:#000;background-color:#fff;font-family:Georgia,'Bookman Old Style',Verdana;font-size:14px;text-align:center;}
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    var reqs=$('#required').val().split(','),
    for(var i=0; i<reqs.length; i++){
    $('#mailform input').each(function(){
    if( fts.indexOf($(this).attr('type')) !=-1 ){
    in Chrome console you can see smth like this:
    Object {order: "968", redirect: "", recipient: "online@the web site. com", subject: "Purchase", required: "Name,Address,E-Mail"…}
    Address: "2"
    E-Mail: "3"
    Name: "1"
    order: "968"
    recipient: "online@the web site. com"
    redirect: ""
    required: "Name,Address,E-Mail"
    subject: "Purchase"
    above goes condition if data is OK
    which now works with any data received from the server
    change it according to the expected data context
    alert('The first form is not sent!\nEverything went wrong...');
    <form name="mailform" action="http://cgi.the web site.com/FormMail.pl" method="post">
            <input type="hidden" value="968" name="order" /> 
            <input type="hidden" name="redirect" /> 
            <input type="hidden" value="online@the web site. com" name="recipient" /> 
            <input type="hidden" value="Purchase" name="subject" /> 
            <input name="required" type="hidden" value="Name,Address,E-Mail" />
              <h2>Personal Identification</h2>
                <div id="fa"><p>Full Name<input name="Name" type="text" id="Name" /></p></div>
           <div id="fa">
              <h2>Contact Details</h2>
                <div id="fab"><p>Address<input name="Address" type="text" id="Address" /></p></div>
                <div id="fac"><p>E-Mail<input name="E-Mail" type="text" id="E-Mail" /></p></div>
              <div id="fza"><input type="button" value="SUBMIT" name="Submit" /></div>
              <div id="fzb"><input type="reset" class="Button" value="ERASE" /></div>
          <form name="orderform" action="control.php" method="post" target="_blank">
            <input type="hidden" name="operation" /> 
            <input type="hidden" name="Total" /> 
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Jan 2014
    It is important to choose right one since the first time. Nice post to hang on. I really loved it the way of the stuff provided in this article.

Thread Information

Users Browsing this Thread

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

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