title: How set value of select option and radio button from datatable using jquery
body: <p>Please help,i am using jQuery Datatables plugin and when i want edit it and send to modal dialog i need to set the value of a select option value "selected" and radio button "checked" ass same from database/datatables. Here's my sample code</p>
  
  <pre><code>&lt;?php
      //Connection Database
      $con = mysqli_connect("localhost","root","","diliport");
      if (mysqli_connect_errno()) {
          echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }
  
      switch ($_POST['type']) {
          //Show Data
          case "get":
              $SQL = mysqli_query($con, "SELECT * FROM passageiro WHERE id='".$_POST['id']."'");
              $return = mysqli_fetch_array($SQL,MYSQLI_ASSOC);
              echo json_encode($return);
              break;
      } 
  ?&gt;
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function showModals(id) {
    waitingDialog.show();
    clearModals();
    if (id) {
      $.ajax({
        type: "POST",
        url: "crud.php",
        dataType: 'json',
        data: {
          id: id,
          type: "get"
        },
        success: function(res) {
          waitingDialog.hide();
          setModalData(res);
        }
      });
    }
    // for new add new data
    else {
      $("#myModals").modal("show");
      $("#myModalLabel").html("New User");
      $("#type").val("new");
      waitingDialog.hide();
    }
  }
  
  //To show data in modal for edit 
  function setModalData(data) {
    $("#myModalLabel").html(data.Nome_passageiros);
    $("#id").val(data.id);
    $("#type").val("edit");
    $("#nome").val(data.Nome_passageiros);
    $('input:radio[name=sex]').val(data.Sexo).checked = true;
    $("#kelas option:selected").val(data.Destinasaun); //don't want to show data to option value selected                                             
    $("#myModals").modal("show");
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form action="" role="form" data-toggle="validator" id="formPassageiro" method="post" class="form-horizontal"&gt;
    &lt;input type="hidden" class="form-control" id="id" name="id"&gt;
    &lt;input type="hidden" class="form-control" id="userid" name="userid"&gt;
    &lt;input type="hidden" class="form-control" id="type" name="type"&gt;
    &lt;thead&gt;
      &lt;div class="row"&gt;
  
        &lt;div class="form-group"&gt;
          &lt;label for="naran" class="col-md-2 col"&gt;Naran Passageiro&lt;/label&gt;
          &lt;input type="text" name="nome" id="nome" placeholder="naran" class="col-md-5 col, highlight" required="" size="50" /&gt;
          &lt;label for="sexo" class="col-md-1 col"&gt;Sexo :&lt;/label&gt;
          &lt;input type="radio" name="sexo" id="sexo" value="Mane" /&gt;
          &lt;label for="mane"&gt;&amp;nbsp;Mane &amp;nbsp;&amp;nbsp;&lt;/label&gt;
          &lt;input type="radio" name="sexo" id="sexo" value="Feto" /&gt;
          &lt;label for="feto"&gt;&amp;nbsp; Feto&lt;/label&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="row"&gt;
        &lt;div class="form-group"&gt;
          &lt;label for="Destinado" class="col-md-2 col"&gt;Destinasaun&lt;/label&gt;
          &lt;label class="style-label"&gt;
            &lt;select class="form-group,col" name="kelas" id="kelas" onchange="ambildata(this.value)+ambilharga(this.value)" size=""&gt;
              &lt;option value=""&gt;&lt;/option&gt;
            &lt;/select&gt;
          &lt;/label&gt;
  
  
    &lt;/thead&gt;
  
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>