title: fetching value from multiple forms and displaying in the appropriate field based on form id
body: <p>I have 2 forms on a page with structures </p>
  
  <pre><code>&lt;div id="tabs-7"&gt;
      &lt;form action="/admin/languages" id="1" class="mainForm" method="POST"&gt;
          &lt;fieldset&gt;
              &lt;div class="widget"&gt;
  
                  &lt;input type="hidden" maxlength="40"class="autoF" name="base" id="base" value="&lt;?php echo base_url(); ?&gt;" /&gt;
                  &lt;input type="hidden" maxlength="40"class="autoF" id="lang_id" name="lang_id" value="1" /&gt;
  
  
                  &lt;div class="rowElem"&gt;
                      &lt;label&gt;Calender&lt;/label&gt; 
                      &lt;div class="rowElem noborder" &gt;
                          &lt;label&gt;Date:&lt;/label&gt;
                          &lt;div class="formLeft"&gt;
                              &lt;input type="text"  name="date" class="datepicker date" value="&lt;?php echo isset($data['1']['date']['text']) ? $data['1']['date']['text'] : ""; ?&gt;" /&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;label&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Note:&lt;/label&gt;
                      &lt;div class="formLeft"&gt;
  
  
                          &lt;?php
                          if (!empty($data['1']['calender_contents'])) {
                              $text = preg_replace('/\s+/', ' ', $data['1']['calender_contents']['text']);
                          }
                          ?&gt;
                          &lt;textarea name="calender_contents"  class="auto limit calender_contents" style="min-width: 600px;max-width: 600px;min-height:80px;max-height: 80px;"&gt;&lt;?php echo isset($data['1']['calender_contents']['text']) ? $text : ""; ?&gt;&lt;/textarea&gt;
                      &lt;/div&gt;
                      &lt;div class="rowElem "&gt;&lt;input type="button" value="Add Note" class="blueBtn left addnote"&gt;&lt;/div&gt;
                  &lt;/div&gt;
  
  
                  &lt;div class="rowElem "&gt;&lt;input type="submit" value="Save" class="greenBtn right"&gt;&lt;/div&gt;
  
              &lt;/div&gt;
          &lt;/fieldset&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;div id="tabs-8"&gt;
      &lt;form action="/admin/languages" id="2" class="mainForm" method="POST"&gt;
          &lt;fieldset&gt;
              &lt;div class="widget"&gt;
  
                  &lt;input type="hidden" maxlength="40"class="autoF" name="base" id="base" value="&lt;?php echo base_url(); ?&gt;" /&gt;
                  &lt;input type="hidden" maxlength="40"class="autoF" id="lang_id" name="lang_id" value="2" /&gt;
  
  
                  &lt;div class="rowElem"&gt;
                      &lt;label&gt;Calender&lt;/label&gt; 
                      &lt;div class="rowElem noborder" &gt;
                          &lt;label&gt;Date:&lt;/label&gt;
                          &lt;div class="formLeft"&gt;
                              &lt;input type="text"  name="date" class="datepicker date" value="&lt;?php echo isset($data['2']['date']['text']) ? $data['2']['date']['text'] : ""; ?&gt;" /&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;label&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Note:&lt;/label&gt;
                      &lt;div class="formLeft"&gt;
  
  
                          &lt;?php
                          if (!empty($data['2']['calender_contents'])) {
                              $text = preg_replace('/\s+/', ' ', $data['1']['calender_contents']['text']);
                          }
                          ?&gt;
                          &lt;textarea name="calender_contents" class="auto limit calender_contents" style="min-width: 600px;max-width: 600px;min-height:80px;max-height: 80px;"&gt;&lt;?php echo isset($data['2']['calender_contents']['text']) ? $text : ""; ?&gt;&lt;/textarea&gt;
                      &lt;/div&gt;
                      &lt;div class="rowElem "&gt;&lt;input type="button" value="Add Note" class="blueBtn left addnote"&gt;&lt;/div&gt;
                  &lt;/div&gt;
  
  
                  &lt;div class="rowElem "&gt;&lt;input type="submit" value="Save" class="greenBtn right"&gt;&lt;/div&gt;
  
              &lt;/div&gt;
          &lt;/fieldset&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and javascript :</p>
  
  <pre><code> $(".datepicker").datepicker({
          defaultDate: +7,
          autoSize: true,
          appendText: '(yyyy-mm-dd)',
          dateFormat: 'yy-mm-dd',
          onClose: function(dateText, inst) {
             var form = $(this).closest("form");
               var formID = $(form).attr("id");
               console.log(formID);
               if(formID == "1"){
                    formID = 1;
                     }
                     else{
                       formID = 2;  
  
                     }
              var lang_id = formID;
              var date = $(".date").val();
              console.log(lang_id);
              console.log(date);
  
              $.ajax({
                  type: 'POST',
                  url: "/admin/getnote",
                  dataType: "json",
                  data: {"date": date, "lang_id": lang_id},
                  success: function(data) {
  
                      console.log(data.arr[0]);
  
                       if(data.arr[0] != undefined){
                      $('.calender_contents').val(data.arr[0].note);
                      $('.date').val(data.arr[0].date);
                       }
                        else {
                           $('.calender_contents').val("");                         
                       }
                  }
  
              });
  
          }
      });
  </code></pre>
  
  <p>I am able to get the value from the database in the first tab that is tab 7 fine and value
  but when use the date picker in the second form to its value also gets displayed in the first table so was looking for some advise as how i can combine <code>$(this).closest("form");</code> with  these fields  </p>
  
  <pre><code>$('.calender_contents').val(data.arr[0].note);
                          $('.date').val(data.arr[0].date);
  </code></pre>
  
  <p>so that i could get value in the specific form field . Thank you.</p>