title: How to insert radio button value into the database?
body: <p>I want to insert selected radio button value into the database. just "yes" or "no". if anyone can give me an idea it would be a great help. I am using codeigniter framework. Thanks in advance.</p>
  
  <p><strong>Model</strong></p>
  
  <pre><code>function add_reservation($reservation_model) {
          return $this-&gt;db-&gt;insert('reservations', $reservation_model);
      }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>function add_reservation() {
          $reservation_model = new Reservation_model();
          $reservation_service = new Reservation_service();
  
          $reservation_model-&gt;set_date_cal(trim($this-&gt;input-&gt;post('date', TRUE)));
          $reservation_model-&gt;set_date(strtotime($this-&gt;input-&gt;post('date', TRUE)));
          $reservation_model-&gt;set_title(trim($this-&gt;input-&gt;post('selected_hall', TRUE)));
          $reservation_model-&gt;set_type(trim($this-&gt;input-&gt;post('selected_time', TRUE)));
          $reservation_model-&gt;set_description(trim($this-&gt;input-&gt;post('name', TRUE)));
          $reservation_model-&gt;set_advanced_payment_status(trim($this-&gt;input-&gt;post('advanned_paid_radio_button', TRUE)));
          $reservation_model-&gt;set_paid_amount(trim($this-&gt;input-&gt;post('paid_amount', TRUE)));
          $reservation_model-&gt;set_fax(trim($this-&gt;input-&gt;post('fax', TRUE)));
          $reservation_model-&gt;set_telephone_number(trim($this-&gt;input-&gt;post('telephone', TRUE)));
          $reservation_model-&gt;set_address(trim($this-&gt;input-&gt;post('address', TRUE)));
          $reservation_model-&gt;set_menu_no(trim($this-&gt;input-&gt;post('selected_menu_number', TRUE)));
          $reservation_model-&gt;set_menu_price_per_plate(trim($this-&gt;input-&gt;post('menu_price', TRUE)));
          $reservation_model-&gt;set_is_deleted('0');
  
          $this-&gt;db-&gt;last_query();
  
          echo $reservation_service-&gt;add_reservation($reservation_model);
      }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;label for="advanced_paid"&gt;Advanced paid&lt;/label&gt;                        
                          &lt;div id="advanned_paid_radio_button"&gt;                           
                              &lt;input type="radio" onclick="myFunction()" name="optionsRadios" id="yes" value="yes"&gt; Yes
                              &lt;input type="radio" onclick="myNoFunction()" name="optionsRadios" id="no" value="no"&gt; No
  
                          &lt;/div&gt;
  </code></pre>
  
  <p>In the javascript i have this.</p>
  
  <pre><code>                 function myFunction() {                               
  
                         if ($('input[id="yes').is(':checked')) {
                              $('div[id="paid"]').show();
                          }
                          if ($('input[id="no"]').is(':checked')) {
                              $('div[id="paid"]').hide();
                          }
  
                      }
  
                      function myNoFunction() {
                          if ($('input[id="no"]').is(':checked')) {
                              $('div[id="paid"]').hide();
                          }
                      } 
  </code></pre>