Advertisement
Ekhel

Manipulasi Dropdown

Jan 16th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $('select[name="id_ssh"]').on('change', function() {
  2.       var id_ssh = $(this).val();
  3.       if(id_ssh) {
  4.           $.ajax({
  5.               url: '<?php echo base_url("econtrolling_users/get_harga/") ?>'+id_ssh,
  6.               type: "GET",
  7.               dataType: "json",
  8.               success:function(data) {
  9.                   $('select[name="harga"]').empty();
  10.                   $.each(data, function(key, value) {
  11.                       $('select[name="harga"]').append('<option value="'+ value.id_ssh +'">'+ formatNumber(value.harga)+'</option>');
  12.                   });
  13.               }
  14.           });
  15.       }else{
  16.           $('select[name="harga"]').empty();
  17.       }
  18.   });
  19.  
  20.   $('select[name="id_ssh"]').on('change', function() {
  21.       var id_ssh = $(this).val();
  22.       if(id_ssh) {
  23.           $.ajax({
  24.               url: '<?php echo base_url("econtrolling_users/get_satuan/") ?>'+id_ssh,
  25.               type: "GET",
  26.               dataType: "json",
  27.               success:function(data) {
  28.                   $('select[name="satuan"]').empty();
  29.                   $.each(data, function(key, value) {
  30.                       $('select[name="satuan"]').append('<option value="'+ value.id_ssh +'">'+ value.satuan+'</option>');
  31.                   });
  32.               }
  33.           });
  34.       }else{
  35.           $('select[name="satuan"]').empty();
  36.       }
  37.   });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement