2017-10-14 20 views
0

2つのモーダルを呼び出す2つのボタンがあるページがあります。1ページ、2つのモーダル(2つの異なるアクション)

各モーダルには[サブミット]ボタンがあり、私は異なるアクションを実行したいと思います。

私の問題は、2番目のモーダルを開いてフォームを送信しようとすると、最初のモーダルは必須フィールドの警告を表示することです。

アクションを個別に実行する方法は?この場合はORを送信する連絡先フォームを追加する、またはドキュメントフォームを送信するフォームを送信する

ありがとうございます。

ボタン1つのADD CONTACT:

<a data-toggle="modal" href="#add_contact"><i class="icon-user-plus"></i> <? echo $msg['new']; ?> <? echo $msg['contact']; ?></a> 

BUTTON 2 ADD文献

<a data-toggle="modal" href="#add_document"><i class="icon-user-plus"></i> <? echo $msg['new']; ?> <? echo $msg['document']; ?></a> 

1STモーダルCONTACT

<!-- Add Contact MODAL --> 
     <div id="add_contact" class="modal fade"> 
      <div class="modal-dialog"> 
       <div class="modal-content"> 
        <div class="modal-header"> 
         <button type="button" class="close" data-dismiss="modal">&times;</button> 
         <h5 class="modal-title"><? echo $msg['add_contact']; ?></h5> 
        </div> 
        <form method="post" id="message_add" class="form-validate-jquery" action="suppliers_inc.sql.php"> 

         <input type="hidden" name="a" value="add_contact" /> 
         <input type="hidden" name="supplier_id" value="<? echo $supplier_id ?>" /> 

         <div class="modal-body"> 
          <div class="form-group"> 
           <div class="row"> 
            <div class="col-sm-6"> 
             <label><? echo $msg['contact_type']; ?> <span class="text-danger">*</span></label> 
             <select name="contact_type_id" class="select-search" required="required" data-placeholder=""> 
             <?php 
              $query_contact_type = "SELECT DISTINCT type_id, type_description FROM supplier_contacts_type ORDER BY type_description"; 
              $result_contact_type = $mysqli->query($query_contact_type); 
              while ($row_contact_type = $result_contact_type->fetch_assoc()) { 
               echo "<option></option>"; 
               echo "<option value=\"{$row_contact_type['type_id']}\">"; 
               echo $row_contact_type['type_description']; 
               echo "</option>"; 
              } 
             ?> 
             </select> 
            </div> 

            <div class="col-sm-6"> 
             <label><? echo $msg['position']; ?> <span class="text-danger">*</span></label> 
             <input type="text" name="contact_position" required="required" class="form-control"> 
            </div> 

           </div> 
          </div> 

          <div class="form-group"> 
           <div class="row"> 
            <div class="col-sm-6"> 
             <label><? echo $msg['name']; ?> <span class="text-danger">*</span></label> 
             <input type="text" name="contact_name" required="required" class="form-control"> 
            </div> 

            <div class="col-sm-6"> 
             <label><? echo $msg['surname']; ?> <span class="text-danger">*</span></label> 
             <input type="text" name="contact_surname" required="required" class="form-control"> 
            </div> 
           </div> 
          </div> 

          <div class="form-group"> 
           <div class="row"> 
            <div class="col-sm-4"> 
             <label><? echo $msg['telephone']; ?> <span class="text-danger">*</span></label> 
             <input type="text" name="contact_telephone" placeholder="Telefone FIXO" data-mask="99 9999-9999" required="required" class="form-control"> 
            </div> 

            <div class="col-sm-4"> 
             <label><? echo $msg['int']; ?></label> 
             <input type="text" name="contact_int" class="form-control"> 
            </div> 

            <div class="col-sm-4"> 
             <label><? echo $msg['hours']; ?></label> 
             <input type="text" name="contact_hours" class="form-control"> 
            </div> 
           </div> 
          </div> 

          <div class="form-group"> 
           <div class="row"> 
            <div class="col-sm-3"> 
             <label><? echo $msg['mobile']; ?></label> 
             <input type="text" name="contact_mobile" placeholder="Celular" data-mask="99 9-9999-9999" class="form-control"> 
            </div> 

            <div class="col-sm-6"> 
             <label><? echo $msg['email']; ?></label> 
             <input type="text" name="contact_email" class="form-control"> 
            </div> 

            <div class="col-sm-3"> 
             <label><? echo $msg['date_of_birth']; ?></label> 
             <input type="text" name="contact_date_of_birth" placeholder="dd/mm/aaaa" data-mask="99/99/9999" class="form-control"> 
            </div>          
           </div> 
          </div> 

          <div class="form-group"> 
           <div class="row"> 

            <div class="col-sm-4"> 
             <div class="checkbox"> 
              <label> 
               <input type="checkbox" name="contact_default" class="control-primary"> 
               <? echo $msg['default_contact']; ?> 
              </label> 
             </div> 
            </div> 

           </div> 
          </div> 

         </div> 

         <div class="modal-footer"> 
          <button type="button" class="btn btn-link" data-dismiss="modal"><? echo $msg['close']; ?></button> 
          <button type="submit" class="btn btn-primary"><? echo $msg['save']; ?> <i class="icon-arrow-right14 position-right"></i></button> 
         </div> 

        </form> 
       </div> 
      </div> 
     </div> 
     <!-- /Add Contact MODAL --> 

2NDモーダル文書に

  <!-- Add Document MODAL --> 
     <div id="add_document" class="modal fade"> 
      <div class="modal-dialog"> 
       <div class="modal-content"> 
        <div class="modal-header"> 
         <button type="button" class="close" data-dismiss="modal">&times;</button> 
         <h5 class="modal-title"><? echo $msg['add_document']; ?></h5> 
        </div> 
        <form method="post" id="document_add" class="form-validate-jquery" action="suppliers_inc.sql.php"> 

         <input type="hidden" name="a" value="add_document" /> 
         <input type="hidden" name="supplier_id" value="<? echo $supplier_id ?>" /> 

         <div class="modal-body"> 
          <div class="form-group"> 
           <div class="row"> 
            <div class="col-sm-6"> 
             <label><? echo $msg['document_classification']; ?> <span class="text-danger">*</span></label> 
             <select name="classification_id" class="select-search" required="required" data-placeholder=""> 
             <?php 
              $query_document_classification = "SELECT DISTINCT classification_id, classification_description FROM supplier_documents_classification ORDER BY classification_description"; 
              $result_document_classification = $mysqli->query($query_document_classification); 
              while ($row_document_classification = $result_document_classification->fetch_assoc()) { 
               echo "<option></option>"; 
               echo "<option value=\"{$row_document_classification['classification_id']}\">"; 
               echo $row_document_classification['classification_description']; 
               echo "</option>"; 
              } 
             ?> 
             </select> 
            </div> 

           </div> 
          </div> 

          <div class="form-group"> 
           <div class="row"> 
            <div class="col-sm-12"> 
             <label><? echo $msg['description']; ?> <span class="text-danger">*</span></label> 
             <input type="text" name="document_description" required="required" class="form-control"> 
            </div> 
           </div> 
          </div> 

          <div class="form-group"> 
           <div class="row"> 
            <div class="col-sm-4"> 
             <label><? echo $msg['issue_date']; ?></label> 
             <input type="text" name="contact_date_of_birth" placeholder="dd/mm/aaaa" data-mask="99/99/9999" class="form-control"> 
            </div> 

            <div class="col-sm-4"> 
             <label><? echo $msg['expiry_date']; ?></label> 
             <input type="text" name="contact_date_of_birth" placeholder="dd/mm/aaaa" data-mask="99/99/9999" class="form-control"> 
            </div> 
           </div> 
          </div> 

          <div class="form-group"> 
           <div class="row"> 

            <div class="col-sm-4"> 
             <div class="checkbox"> 
              <label> 
               <input type="checkbox" name="contact_default" class="control-primary"> 
               <? echo $msg['expiry_notification']; ?> 
              </label> 
             </div> 
            </div> 
            <div class="col-sm-4"> 
             <div class="checkbox"> 
              <label> 
               <input type="checkbox" name="contact_default" class="control-primary"> 
               <? echo $msg['lock_supplier']; ?> 
              </label> 
             </div> 
            </div> 

           </div> 
          </div> 

         </div> 

         <div class="modal-footer"> 
          <button type="button" class="btn btn-link" data-dismiss="modal"><? echo $msg['close']; ?></button> 
          <button type="submit" class="btn btn-primary"><? echo $msg['save']; ?> <i class="icon-arrow-right14 position-right"></i></button> 
         </div> 

        </form> 
       </div> 
      </div> 
     </div> 
     <!-- /Add Document MODAL --> 
を追加

答えて

0

問題はjavascript/jqueryフォーム送信ハンドラ関数にある必要があります

$('form#message_add').on('submit',function(){ 
    //do something 
}); 

$('form#document_add').on('submit',function(){ 
    //do something 
}); 
関連する問題