title: How to add form data to a bootstrap modal in the same page by using jQuery?
body: <p>I have a requirement and trying to write code for Where user enters/selects some information in form then clicks on Submit button then a popup window(bootstrap modal) appears with just one single input box where user just types a name for that selection. What I am doing here is once user gives some information in form &amp; after clicks on submit button I am storing that form before popup modal opens(in the middle of after user clicks on submit button and a popup window opens I am storing the given form inputs and fetching that last inserted record id and binding that id to a hidden input field in the popup modal), after popup window opens user types a name and clicks on Save button then I will be updating that record by using the same record id. The problem Am facing here is after user enters all form data and he clicks on submit button I am storing this data in the database before a popup window opens, after popup window opens in popup window if user clicks on close or Esc button without giving a name then that form data is already saved with empty name becoz user didn't give a name in popup box because as he clicks on 'close' or 'Esc' button but my requirement is if user doesn't give a name then that record shouldn't be stored in the database.</p>
  
  <p>My Form code:</p>
  
  <pre><code>&lt;form method="post" action="" id="my_form_id" class="my_form_class"&gt; 
   &lt;div class="col-md-6 col-sm-6 col-xs-12"&gt;
       &lt;input type="radio" name="my_input_name_116" class="all select_option" data-id="116" value="all"&gt;
       &lt;label for="all"&gt;All&lt;/label&gt;
       &lt;input type="radio" name="my_input_name_116" class="yes select_option" data-id="116" value="yes"&gt;
       &lt;label for="yes"&gt;Yes&lt;/label&gt;
       &lt;input type="radio" name="my_input_name_116" class="no select_option" data-id="116" value="no" checked&gt;
        &lt;label for="no"&gt;No&lt;/label&gt;
   &lt;/div&gt;
  &lt;button type="button" class="btn btn-success" data-toggle="modal" data-target="#rsModal" data-backdrop="static" data-keyboard="false" id="save_run_setup"&gt;SAVE RUN SETUP&lt;/button&gt;
  </code></pre>
  
  <p></p>
  
  <p>My bootstrap modal code:</p>
  
  <pre><code>&lt;div class="modal fade" id="rsModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&gt;
      &lt;div class="modal-dialog"&gt;
          &lt;div class="modal-content"&gt;
              &lt;div class="modal-header"&gt;
                  &lt;!--&lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&amp;times;&lt;/button&gt;--&gt;
                  &lt;h4 class="modal-title" id="myModalLabel"&gt;Run Setup Name&lt;/h4&gt;
              &lt;/div&gt;
              &lt;div class="modal_failure run_setup_error"&gt;
                  &lt;p&gt;&lt;span class="add_failure_msg"&gt;&lt;/span&gt;&lt;/p&gt;
              &lt;/div&gt;
              &lt;div class="popup_success run_setup_success"&gt;
                  &lt;p&gt;&lt;span class="add_success_msg"&gt;&lt;/span&gt;&lt;/p&gt;
              &lt;/div&gt;
              &lt;form method="post" action="" id="add_rs_modal"&gt;
                  &lt;div class="modal-body"&gt;
                      &lt;input type="hidden" class="form-control modal_user_id" id="user_id" name="user_id" value=""&gt;
                      &lt;input type="hidden" class="form-control modal_rs_row_id" id="rs_row_id" name="rs_row_id" value=""&gt;
                      &lt;div class="form-group"&gt;
                          &lt;!--&lt;label for="module-name"&gt;Run setup name&lt;/label&gt;--&gt;
                          &lt;input type="text" class="form-control modal_runsetup_name" name="modal_runsetup_name" placeholder="Enter Run Setup Name" value="" required&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-footer"&gt;
                      &lt;!--&lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;--&gt;
                      &lt;button type="button" class="btn btn-success" class="add_runsetup_name" id="add_runsetup_name"&gt;Save Run Setup&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/form&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My question here is how to carry the form input data along with a name which user is going to give in the popupbox, if user doesn't give a name then I will not save that previous form data? Any help would be appreciated.  </p>
  
  <p>Edited :</p>
  
  <p>What I am doing is after user gives the input to the form "my_form_id" he clicks on 'save_run_setup' button then in ajax call I am storing this form values into a table and getting the last inserted row id and putting that row id in popup modal(which opens after this ajax call) asking user to enter a name for this form selection and updating that revious record with this 'name' given in modal popup. But If user doesn't give a any name then I already saved a record after user clicks on 'Save Run Setup' button. My requirement is I have to either append 'my_form_id' form data to bootstrap modal or modal input value to this form.</p>