2016-10-16 20 views
0

ajaxを使用して単一の送信ボタンでフォームを送信したいとします。1つの送信ボタンでフォームを送信するにはどうすればよいですか?

<h:head> 
     <script> 

      function submitOthers() { 
       document.getElementById('form1').submit(); 
       document.getElementById('form2').submit(); 
      } 
     </script> 

    </h:head> 

1つのボタンで複数のHTMLフォームを送信できるかどうかを知りたいと思います。ここ は、以下の私のコードです:

<h:form id="form1" > 

        <p:panel header="Adres Bilgilerini giriniz" style="width: 500px;"> 
         <h:panelGrid columns="4" > 

          <p:selectOneMenu value="#{category.catname}" id="cat" filter="true" filterMatchMode="contains"> 

           <f:selectItems value="#{category.categoryName}"/> 
           <p:ajax update="scat" /> 
          </p:selectOneMenu>    

          <p:selectOneMenu value="#{category.subcatname}" id="scat" filter="true" filterMatchMode="contains"> 

           <f:selectItems value="#{category.subCategoryName}"/> 
           <p:ajax update="scat1"/> 
          </p:selectOneMenu> 

    <br></br> 

      <h:form id="form2"> 
       <p:growl id="msgs" showDetail="true" /> 

       <p:panelGrid columns="2"> 
        <p:outputLabel for="tarihIcYazisma" value="Ic Yazısma Tarih" /> 
        <p:calendar id="tarihIcYazisma" value="#{calendarView.date10}" pattern="dd/MM/yyyy" /> 
       </p:panelGrid> 

       <p:panelGrid columns="2" > 
        <p:outputLabel for="icYazismaNo" value="Ic Yazısma No" /> 
        <p:inputText id="icYazismaNo" value="#{calendarView.aciklama1}" /> 
       </p:panelGrid> 

       <p:panelGrid columns="2"> 
        <p:outputLabel value="" /> 
        <p:commandButton value="Submit" update="msgs" actionListener="#{calendarView.click()}" icon="ui-icon-check" style="display: none" /> 
       </p:panelGrid> 
       <p:dialog modal="true" resizable="false" header="Values" widgetVar="dlg" showEffect="fold"> 
        <p:panelGrid id="display" columns="2" columnClasses="label,value"> 

         <p:outputLabel value="tarihIcYazisma" /> 
         <p:outputLabel value="#{calendarView.date10}"> 
          <f:convertDateTime pattern="dd/MM/yyyy" /> 
         </p:outputLabel> 

        </p:panelGrid> 
       </p:dialog> 
      </h:form> 

私はスクリプトを試してみましたが、それらは動作しません。 form1、form2のために隠されたボタン。

<h:form id="form3"> 
      <p:commandButton onclick="submitOthers()" ></p:commandButton> 
     </h:form> 

おかげで、 Merve

+0

submitOthers関数は機能しませんか? – Jecoms

+0

他の機能はどうすればできますか? –

答えて

0

私は唯一のいずれかの形式を取得します。どうして?

<script> 

      function submitOthers() { 
       alert('test'); 

       function submitOthers() { 
        setTimeout(function() { 
         document.getElementById("form1").submit(); 
        }, 3000); 

        setTimeout(function() { 
         document.getElementById("form2").submit(); 
        }, 6000); 
       } 
      } 
     </script> 
関連する問題