Skip to main content
Topic: Javascript ClientEvents Working on Add Page but not in Edit Page (Read 1891 times) previous topic - next topic

Javascript ClientEvents Working on Add Page but not in Edit Page

Hi All PHPRad Lovers...

I have facing the problem. I had using PHPRAD V2.7.3

In my project i put Clientevents :
Code: [Select]
var varTempo = 0;

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


   
    let arrCust = pro.split(' | ');

    var dd = document.getElementById('ctrl-Sales');
    for (var i = 0; i < dd.options.length; i++) {
        if (dd.options[i].value === arrCust[1]) {
            dd.selectedIndex = i;
            break;
        }
    }
   
    //Isi Field Sesuai nilai array
    $('input[name="Limit_Kredit"]').val(arrCust[2]);
    $('input[name="Total_Piutang"]').val(arrCust[3]);
    $('input[name="Tempo_Pembayaran"]').val(arrCust[4]);
    $('input[name="Contact_Person"]').val(arrCust[5]);
   

    //Tampilkan Nilai PPN
    var nppn = 0;
    var hppn = arrCust[6];
    hppn = hppn.replace(/^\s+|\s+$/gm,'');
    if (hppn === "Y") {
        nppn = 10;
    } else {
        nppn = 0;
    }
    $('input[name="PPN"]').val(nppn);

    //Set Tanggal Tempo Pembayaran
    varTempo = arrCust[4]
    setTglTempo();
   
    //Hitung Total
    nilaiPPN = nppn;
    hitungTotal();
});


$(document.body).on('change', 'input[name="Tgl_Rencana_Kirim"]', function() {
    //Set Tanggal Tempo Pembayaran
    setTglTempo();
});

$(document.body).on('change keyup input', 'input[name="Tempo_Pembayaran"]', function() {
    //Set Tanggal Tempo Pembayaran
    varTempo = $(this).val();
    setTglTempo();
});


function setTglTempo() {
    var trk = new Date(document.getElementById('ctrl-Tgl_Rencana_Kirim').value);

    trk.setDate(trk.getDate() + parseInt(varTempo));
   
    var ttp = trk.toISOString().slice(0, 10);
   
    $('input[name="Tgl_Tempo_Pembayaran"]').val(ttp);
};


var disRupiah = 0;
var disPersen = 0;
var nilaiPPN =0;


$(document.body).on('change keyup input', 'input[name="Diskon_Persen"]', function() {
    //Hitung Total
    disPersen = $(this).val();
    hitungTotal();
});

$(document.body).on('change keyup input', 'input[name="Diskon_Rupiah"]', function() {
    //Hitung Total
    disRupiah = $(this).val();
    hitungTotal();
});

$(document.body).on('change keyup input', 'input[name="PPN"]', function() {
    //Hitung Total
    nilaiPPN = $(this).val();
    hitungTotal();
});

function hitungTotal() {
    var gtADP = 0;
    var gtAD = 0;
    var gtAP = 0;

    gt = document.getElementById('ctrl-Grand_Total').value;
    alert(gt);
   
    gtADP = parseInt(gt) * parseInt(disPersen) / 100;
    gtAD = parseInt(gt) - gtADP - parseInt(disRupiah);
    $('input[name="GT_AD"]').val(gtAD);
   
    gtAP = gtAD + (gtAD * parseInt(nilaiPPN) / 100);
    $('input[name="GT_AP"]').val(gtAP);
};

The problem is, that script can running properly on Add Page, But not Running ini Edit Page.