Skip to main content
Topic: Set Date (Date Picker) Value from ClientEvents (Read 2514 times) previous topic - next topic

Set Date (Date Picker) Value from ClientEvents

Hi... can anyone help me.
I just want to make automatically change a date (date-picker: tgl_perubahan) value to today when user change the price (harga_satuan) value.
This is my script on clientevents:
Code: [Select]
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!

var yyyy = today.getFullYear();
if(dd<10){dd='0'+dd} if(mm<10){mm='0'+mm} today = yyyy+'-'+mm+'-'+dd;

$(document.body).on('change keyup input', 'input[name="harga_satuan"]', function() {
    $('#ctrl-tgl_perubahan').val(today);
});
Note :
#ctrl-tgl_perubahan : id of a date field
harga_satuan : name of a price field



Re: Set Date (Date Picker) Value from ClientEvents

Reply #2
Hi jameswilliam, thanks for your advice.

I actually avoid using the timestamp, because what I want is to record the change_date only if the price field changes.
if the user changes other fields besides the price field then the change_date should not change.

 

Re: Set Date (Date Picker) Value from ClientEvents

Reply #3
Every field has an id, use that to list for change and then assign your date. Check the client events in Add/Edit Page Field Properties, there are example codes there.