RADSYSTEMS 7.1.2 multiply issue

Hi Everyone
does any know how to multiply two fields and place the result in a third field of the same table. I want to multiply my quantity field by my price field and place the result in a field called total price. I’m new to laravel and could really do with some help ,thanks

You can use the Client Events for the Classic project. When you open the Client Events located on the Add page Field Properties, then add the below code and modify it, changing ctrl-first_field, ctrl-second_field, and ctrl-total_field with yours appropriately.

$('#ctrl-first_field, #ctrl-second_field').on('change', function(){
    $("#ctrl-total_field").val(parseFloat($("#ctrl-first_field").val()) * parseFloat($("#ctrl-second_field").val()));
});

Thankyou so much for the code it works well when I call the add page direct. However when the add page is embedded in a view page via Page Design it doesnt work. It also doesn’t work if I change to a dynamic table. any feedback would be really welcome and appreciated , thankyou.

To work with modals or if your function is not triggered with the above code, you will need to bind the event listener to the root node or document and it should work. Check below for an example. If you want to do calculations on table row it is somewhat difficult, it is advisable to stick to the regular form when you plan on doing calculations, then use dynamic forms when you have no plans for that.

$(document).on('change', '#ctrl-first_field, #ctrl-second_field', function(e) {
    $("#ctrl-total_field").val(parseFloat($("#ctrl-first_field").val()) * parseFloat($("#ctrl-second_field").val()));
});

the codes written here are jQuery codes, so if you find a jQuery code that you want to implement in your project it should work with a few changes.

You could also make a custom field that does the calculation, so if it doesn’t refresh as you add the values, you’ll have to do it through code.