This topic is locked
[SOLVED]

 calculating on the fly with button

8/9/2018 7:57:07 AM
PHPRunner General questions
ruzgarajans author

hi, sorry Im little speak english,
1-there is a trigger below,

2-how to trigger the button instead of the field,

3-I need an calculating button

thank you very much..
referance: http://asprunner.com/forums/topic/23269-calculating-order-totals-on-the-fly/

screen:


var ctrlhesapla_butonu = Runner.getControl(pageid, 'hesapla_butonu');

function func() {

ctrlurun_hizmet_toplami.setValue((Number(ctrlurun_fiyati.getValue())+ Number(ctrldiger_urun_toplami.getValue()))+ Number(ctrlvale_urun.getValue()) );

ctrlyuzde_tl.setValue(Number(ctrlurun_hizmet_toplami.getValue()) * Number(ctrlmusteri_grubu_yuzde.getValue()));

ctrltoplam_tutar.setValue(Number(ctrlurun_hizmet_toplami.getValue())- Number(ctrlyuzde_tl.getValue()));

};
ctrlhesapla_butonu.on('click', func);
C
cristi 8/13/2018

In your custom button "client before" event you could add this (just an example):

var number1= document.getElementById('value_number1_1').value;

var number2= document.getElementById('value_number2_1').value;

var total=parseInt(number1)+parseInt(number2);

document.getElementById('value_total_1').value=total;


You need to check for element id in your html code and change the code accordingly.

Of course this is a very basic code - it does not have error catching - for example if you enter a string instead of a number you will get a "Nan" error but it should do the work.

ruzgarajans author 8/14/2018



In your custom button "client before" event you could add this (just an example):

var number1= document.getElementById('value_number1_1').value;

var number2= document.getElementById('value_number2_1').value;

var total=parseInt(number1)+parseInt(number2);

document.getElementById('value_total_1').value=total;


You need to check for element id in your html code and change the code accordingly.

Of course this is a very basic code - it does not have error catching - for example if you enter a string instead of a number you will get a "Nan" error but it should do the work.


Thank you very much..
button is work.

var number1= document.getElementById('value_number1_field_1').value;

var number2= document.getElementById('value_number2_field_1').value;

var total=parseInt(number1)+parseInt(number2);

document.getElementById('value_total_field').value=total;


when values change,

how can I do verification
(etc: buton change color or total field message, or button name change )

C
cristi 8/14/2018



Thank you very much..
button is work.

var number1= document.getElementById('value_number1_field_1').value;

var number2= document.getElementById('value_number2_field_1').value;

var total=parseInt(number1)+parseInt(number2);

document.getElementById('value_total_field').value=total;


when values change,

how can I do verification
(etc: buton change color or total field message, or button name change )


You can use this.