Forums

Sum if

Savadori 22 Oct, 2019
[font][/font]
Sorry, my English

I have been trying for weeks to make my form work without success

I have to sum up several text fields if Radios group is "yes"
Help!!!!



js
window .addEvent ( 'domready' , function () {

$ ( 'field_radios' ) .addEvent ( 'change' , checkYes);


op('#1').on('change', operazione);
op('#2').on('change', operazione);
op('#3').on('change', operazione);
op('#4').on('change', operazione);



function checkYes () {
if ($ ( 'field_radios17' ) .checked === "yes") {
function operazione ()
{
var 1= Number (op('#bambini').val());
var 2= Number (op('#adulti').val());
var 3= Number (op('#transfer').val());
op('#4').val((( 1+ 2) * 3).toFixed(2));

}
}
}

}

Savadori 23 Oct, 2019
Answer
Resolved!

if (op( '#checkbox106' ) .prop("checked") === true) { 

var 1= Number (op('#1').val());
var 2= Number (op('#2').val());
var 3= Number (op('#3').val());
op('#4').val((( 1+ 2) * 3).toFixed(2));

}
This topic is locked and no more replies can be posted.