Skip to main content
Topic: ClientEvents Not Working on Modal (Read 2017 times) previous topic - next topic

ClientEvents Not Working on Modal

 I just trying this simple statement for ClientEvents but it is not working.... 

Code: [Select]
$('body').on('change keyup input', 'input[name="#ctrl-Jumlah"]', function() {
    jml = $(this).val();
    $('#ctrl-Total').val(jml * 2);
});


Re: ClientEvents Not Working on Modal

Reply #2
Yes I did but with no luck.... still no respon...

Re: ClientEvents Not Working on Modal

Reply #3
Code: [Select]
$('body').on('change keyup input', 'input[name="#ctrl-Jumlah"]', function() {
    jml = $(this).val();
    $('#ctrl-Total').val(jml * 2);
});

This script just trying to simplify your sample code from that link... but still not working....  :( 

Re: ClientEvents Not Working on Modal

Reply #4
after trying, trying again, and keep trying.... finally I succeeded...
I share it here for anyone who might need it....

Code: [Select]
var jml = 0;
var hrg = 0;
var tot = 0;

$(document.body).on('change',"#ctrl-Produk",function (e) {
    var pro = $("#ctrl-Produk option:selected").text();
    pro = pro.replace(/ /g,'');

   
    let arrpro = pro.split('|');
    $('input[name="Satuan"]').val(arrpro[1]);
    $('input[name="Harga"]').val(arrpro[2]);
    hrg = arrpro[2];
    setTotal();
});

$(document.body).on('change keyup input', 'input[name="Jumlah"]', function() {
    jml = $(this).val();
    setTotal();
});

$(document.body).on('change keyup input', 'input[name="Harga"]', function() {
    hrg = $(this).val();
    setTotal();
});

function setTotal() {
    tot = parseInt(jml, 10) * parseInt(hrg, 10);
    $('input[name="Total"]').val(tot);
};

Thank you so much @willvin for your response and support.....