Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- $(document).on('change','select[id=jenis_hewan_sel]', function(e){
- var id=$(this).val();
- $.ajax({
- url : "<?php echo base_url();?>form-regis/get_ras_hewan",
- method : "POST",
- data : {id: id},
- async : false,
- dataType : 'json',
- success: function(a){
- var html = '';
- for(var i=0; i<a.length; i++){
- html += '<option value='+a[i].ras_hewan_id+'>'+a[i].nama_ras_hewan+'</option>';
- }
- html1 = '<option value="0" disabled selected>Ras Hewan</option>';
- $("select[id=ras_hewan_sel]").html(html1);
- $(html).appendTo("select[id=ras_hewan_sel]");
- // $('select[id=ras_hewan_sel]').append(html);
- }
- });
- });
- // $(document).on('change','input[id=add-pet]', function(e){
- // var jml = $(this).val();
- // if(jml != ""){
- // for(var i=1;i<=jml;i++){
- // // alert('select[id=jenis_hewan_sel'+i+']');
- // $(document).on('change','select[id=jenis_hewan_sel'+i+']', function(e){
- // var id=$(this).val();
- // $.ajax({
- // url : "<?php echo base_url();?>form-regis/get_ras_hewan",
- // method : "POST",
- // data : {id: id},
- // async : false,
- // dataType : 'json',
- // success: function(a){
- // var html = '';
- // for(var i=0; i<a.length; i++){
- // html += '<option value='+a[i].ras_hewan_id+'>'+a[i].nama_ras_hewan+'</option>';
- // }
- // html1 = '<option value="0" disabled selected>Ras Hewan</option>';
- // // $("select[id=ras_hewan_sel]").html(html1);
- // $("select[id=ras_hewan_sel"+i+"]").html("");
- // for(var i=1;i<=jml;i++){
- // $(html).appendTo("select[id=ras_hewan_sel"+i+"]");
- // // $("select[id=ras_hewan_sel"+i+"]").html(html);
- // }
- // }
- // });
- // });
- // }
- // }
- // });
- $(document).on('change','input[id=add-pet]', function(e){
- var jml = $(this).val();
- if(jml != ""){
- for(var i=1;i<=jml;i++){
- $('select[id=jenis_hewan_sel'+i+']').click(function(){
- var id = $(this).val();
- $.ajax({
- url : "<?php echo base_url();?>form-regis/get_ras_hewan",
- method : "POST",
- data : {id: id},
- async : false,
- dataType : 'json',
- success: function(a){
- var html = '';
- for(var i=0; i<a.length; i++){
- html += '<option value='+a[i].ras_hewan_id+'>'+a[i].nama_ras_hewan+'</option>';
- }
- $("select[id^=ras_hewan_sel"+id+"]").each(function(){
- $("select[id^=ras_hewan_sel"+id+"]").html("");
- $("select[id^=ras_hewan_sel"+id+"]").html(html);
- })
- }
- });
- });
- }
- }
- });
Add Comment
Please, Sign In to add comment