How I can submit two forms with one button?

I have 2 forms that I wanna to submit them with one button in spring mvc

jsp page:

        <form:form id="form1"   method="POST"  modelAttribute="employee" >

        <th>Employee </th></tr>


       <td>Employee ID</td>
       <td><form:input type="number" path="emp_id"/></td>

       <td>Employee Name</td>
       <td><form:input type="text"   path="name"/></td>

       <td><form:label type="text"  path="designation"> </form:label></td>
       <form:select type="text" path="designation">
       <form:option value="select" label="Select"/>
       <form:option value="Developer" label="Developer"/>
       <form:option value="Tester" label="Tester"/>

      <td><form:label   path="location"/></td>
      <form:select type="text"  path="location">
      <form:option value="select" label="select"/>
      <form:option value="Bangalore" label="Bangalore"/>
      <form:option value="Mysore" label="Mysore"/>

      <td>Employee Type</td>
      <td><form:label type="text"  path="employee_type"> </form:label></td>
      <form:select type="text"  path="employee_type">
      <form:option value="select" label="select"/>
      <form:option value="Permanent" label="Permanent"/>
      <form:option value="Contract" label="Contract"/>

      <td><form:hidden  path="${id}"/></tr>

      <form:form id="form2"   method="POST"  modelAttribute="dailyreportAttribute" >

       <th>Daily Report</th>

       <td><form:input name="date"   path="date"  /></td>

       <td>Task Type</td>
       <td><form:label path="task_type"> </form:label></td>
       <form:select type="text" path="task_type">
      <form:option value="select" label="select"/>
      <form:option value="Technical" label="Technical"/>
      <form:option value="Non-Technical" label="Non-Technical"/>

      <td><form:input type="text"   path="description"/></td>
      <td><form:hidden path="${emp_id}"/>


    <button class="button button-gray" onclick="submitform()"><span class="accept"> 
     submitform = function(){
    setTimeOut(function() {
    }, 5000);

I'm trying to submit 2 forms with one submit button. The first table is getting inserted correctly.. but, the second table is getting created but giving the null value. I tried lot. I can't identify where I have done the mistake.

Can anybody help me?

Read more here:

Content Attribution

This content was originally published by Jeena at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: