This topic is locked

If statement in on the fly calculation

3/17/2020 6:09:57 AM
PHPRunner General questions
S
swanside author

Guys,

I am using this for on the fly calculations.

But I only want it to Put a value in the ctrlTotal if the Checkbox called SendToInvoice is checked? So where would I put the If statement in the function area?

Thanks

var ctrlPrice = Runner.getControl(pageid, 'CostPerHour');

var ctrlQuantity = Runner.getControl(pageid, 'AmountOfHours');

var ctrlTotal = Runner.getControl(pageid, 'Total');

var ctrlTax = Runner.getControl(pageid, 'Tax');

var ctrlSubTotal = Runner.getControl(pageid, 'SubTotal');

var ctrlTaxAmount = Runner.getControl(pageid, 'TaxAmount');

var ctrlSendToInvoice = Runner.getControl(pageid,'SendToInvoice');

function func() {
ctrlSubTotal.setValue((+ctrlPrice.getValue()) * (+ctrlQuantity.getValue()));

ctrlTaxAmount.setValue((+ctrlPrice.getValue()) * (+ctrlQuantity.getValue())*(+ctrlTax.getValue()/100));

if ctrlSendToInvoice,

ctrlTotal.setValue((+ctrlPrice.getValue()) * (+ctrlQuantity.getValue())*(+ctrlTax.getValue()/100)+((+ctrlPrice.getValue())*(+ctrlQuantity.getValue())));

};

ctrlPrice.on('keyup', func);

ctrlQuantity.on('keyup', func);

ctrlTax.on('keyup', func);

ctrlSendToInvoice.on('keyup', func);
Myr0n 3/18/2020

If the value of the SendToInvoice is equal to 'on' then should be something like this

> Guys,

I am using this for on the fly calculations.

But I only want it to Put a value in the ctrlTotal if the Checkbox called SendToInvoice is checked? So where would I put the If statement in the function area?

Thanks

var ctrlPrice = Runner.getControl(pageid, 'CostPerHour');

var ctrlQuantity = Runner.getControl(pageid, 'AmountOfHours');

var ctrlTotal = Runner.getControl(pageid, 'Total');

var ctrlTax = Runner.getControl(pageid, 'Tax');

var ctrlSubTotal = Runner.getControl(pageid, 'SubTotal');

var ctrlTaxAmount = Runner.getControl(pageid, 'TaxAmount');

var ctrlSendToInvoice = Runner.getControl(pageid,'SendToInvoice');

function func() {
ctrlSubTotal.setValue((+ctrlPrice.getValue()) * (+ctrlQuantity.getValue()));

ctrlTaxAmount.setValue((+ctrlPrice.getValue()) * (+ctrlQuantity.getValue())*(+ctrlTax.getValue()/100));

if (ctrlSendToInvoice=='on')

{ // if ctrlSendToInvoice is checked do something

ctrlTotal.setValue((+ctrlPrice.getValue()) * (+ctrlQuantity.getValue())*(+ctrlTax.getValue()/100)+((+ctrlPrice.getValue())*(+ctrlQuantity.getValue())));

}else

{
// if dont do something else

}

};

ctrlPrice.on('keyup', func);

ctrlQuantity.on('keyup', func);

ctrlTax.on('keyup', func);

ctrlSendToInvoice.on('keyup', func);


A
ayctech 3/19/2020



Guys,

I am using this for on the fly calculations.

But I only want it to Put a value in the ctrlTotal if the Checkbox called SendToInvoice is checked? So where would I put the If statement in the function area?

Thanks

var ctrlPrice = Runner.getControl(pageid, 'CostPerHour');

var ctrlQuantity = Runner.getControl(pageid, 'AmountOfHours');

var ctrlTotal = Runner.getControl(pageid, 'Total');

var ctrlTax = Runner.getControl(pageid, 'Tax');

var ctrlSubTotal = Runner.getControl(pageid, 'SubTotal');

var ctrlTaxAmount = Runner.getControl(pageid, 'TaxAmount');

var ctrlSendToInvoice = Runner.getControl(pageid,'SendToInvoice');

function func() {
ctrlSubTotal.setValue((+ctrlPrice.getValue()) * (+ctrlQuantity.getValue()));

ctrlTaxAmount.setValue((+ctrlPrice.getValue()) * (+ctrlQuantity.getValue())*(+ctrlTax.getValue()/100));

if ctrlSendToInvoice,

ctrlTotal.setValue((+ctrlPrice.getValue()) * (+ctrlQuantity.getValue())*(+ctrlTax.getValue()/100)+((+ctrlPrice.getValue())*(+ctrlQuantity.getValue())));

};

ctrlPrice.on('keyup', func);

ctrlQuantity.on('keyup', func);

ctrlTax.on('keyup', func);

ctrlSendToInvoice.on('keyup', func);



try

if( $('input[id^=value_id_forma_pago_1_1').is(':checked') ) {

alert('Seleccionado');

}