SHARE
TWEET

option error always sending text as value

a guest Jan 21st, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!-- MODAL BODY -->
  2. <div class="modal-body" id="addModalBody">
  3.     <table class="modal-tab pure-table">
  4.         <div id="errMessage" class="alert alert-danger" role="alert"></div>
  5.         <form id="form-add">
  6.             <input type="hidden" name="id_nilai">
  7.             <input type="hidden" name="is_edit">
  8.             <input type="hidden" name="periode" value="">
  9.             <input type="hidden" name="kyu_id" value="<?=$_GET['kyu']?>">
  10.             <tr>
  11.                 <td>Peserta UKT<span class="required">*</span></td>
  12.                 <td>
  13.                     <select id="list-kenshin" name="id_kenshin" class="form-control">
  14.                 </td>
  15.             </tr>
  16.  
  17.             <table id="nilaiVariable" class="table table-lg table-hover tab-ins-modal"
  18.                 data-show-columns="true"
  19.                 data-search="true"
  20.                 data-show-toggle="true"
  21.                 data-pagination="true"
  22.                 data-resizable="true"
  23.                 data-height="500"
  24.             >
  25.             </table>
  26.     </table>
  27. </div>
  28.  
  29.  
  30. <-- JS -->
  31. <script>
  32. // initialize list-kenshin option data
  33. // json data
  34. var data_kenshin = [
  35.     {
  36.         id_kenshin: "7",
  37.         username: "wawan",
  38.         nim: "21414",
  39.         nik: "1414",
  40.         nama_kenshin: "Ricky",
  41.         jurusan: "Teknik Informatika",
  42.         tingkatan: "Yudansha 1",
  43.         email: "wawan@ganteng.com",
  44.         alamat: "44441",
  45.         hp: "14"
  46.     },
  47.     {
  48.         id_kenshin: "8",
  49.         username: "bso",
  50.         nim: "12323435325",
  51.         nik: "3532545",
  52.         nama_kenshin: "Budhi Santoso",
  53.         jurusan: "Teknik Sistem Perkapalan",
  54.         tingkatan: "Menuju Kyu 3",
  55.         email: "budhi-santoso@bluegaz.co.id",
  56.         alamat: "Taman Duta",
  57.         hp: "0812312479"
  58.     },
  59.     {
  60.         id_kenshin: "10",
  61.         username: "Fadillah A",
  62.         nim: "1927917",
  63.         nik: "0972917927",
  64.         nama_kenshin: "Fadillah Amin",
  65.         jurusan: "Teknik Informatika",
  66.         tingkatan: "Yudansha 1",
  67.         email: "famin@gmail.com",
  68.         alamat: "LLL",
  69.         hp: "8292149"
  70.     },
  71.     {
  72.         id_kenshin: "18",
  73.         username: "noric1902",
  74.         nim: "2011500504",
  75.         nik: "2020202020",
  76.         nama_kenshin: "Ahmad Fauzi",
  77.         jurusan: "Teknik Informatika",
  78.         tingkatan: null,
  79.         email: "ahmad.uji1902@gmail.com",
  80.         alamat: "Jl. Belimbing 1, RT 4 RW 9, Kelapa Dua, Cimanggis",
  81.         hp: "082112710702"
  82.     }
  83. ]
  84.  
  85. var data = '';
  86. res.forEach(function(datas, key) {
  87.     data += '<option value"'+datas.id_kenshin+'">'+datas.nama_kenshin+'</option>';
  88. });
  89. $('#list-kenshin').html(data);
  90.  
  91. // submit event
  92. $('#submit').click(function(e) {
  93.     $('#successMessage').html('');
  94.     $('#errMessage').html('');
  95.  
  96.     e.preventDefault();
  97.     if($('input[name=id_nilai]').val() != '') {
  98.         $('input[name=is_edit]').val('1');
  99.     } else {
  100.         $('input[name=is_edit]').val('0');
  101.     }
  102.  
  103.     $.ajax({
  104.         url: '../json/seleksi/save-nilai.php',
  105.         type: 'post',
  106.         data: $('#addModalBody').find("select, textarea, input").serialize(), // get all inputable/selectable value
  107.         success: function(res) {
  108.             if(!res.error) {
  109.                 $('#addModal').modal('hide');
  110.                 $('#successMessage').show();
  111.                 $('#successMessage').html(res.msg);
  112.                 refresh_data();
  113.             } else {
  114.                 $('#errMessage').show();
  115.                 $('#errMessage').html(err.msg);
  116.             }
  117.         },
  118.         error: function(err) {
  119.             $('#errMessage').show();
  120.             $('#errMessage').html(err.msg);
  121.         }
  122.     });
  123. });
  124. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top