Hi
I want to calculation some fields in a subform based on who is selected in the select field. Please see attachment. subform is cli_sf_money
Thank You for your assistance
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Subform Calculations
Subform Calculations
You do not have the required permissions to view the files attached to this post.
Re: Subform Calculations
Think I have solved this
Called by OnChange on the Who select object
Is there a better way to write this?
Paul
Called by OnChange on the Who select object
Code: Select all
fillwhovalue()
Code: Select all
function fillwhovalue() {
var whoid = $('#' + event.target.id).val();
var prefix = $(event.target).attr('data-nu-prefix');
var fortmon = $('#' + prefix + 'mon_fortamt').val();
$('#' + prefix + 'mon_self').val(0).change();
$('#' + prefix + 'mon_partner').val(0).change();
$('#' + prefix + 'mon_other').val(0).change();
if (whoid == 'S') {
$('#' + prefix + 'mon_self').val(fortmon).change();
} else if (whoid == 'P') {
$('#' + prefix + 'mon_partner').val(fortmon).change();
} else if (whoid == 'O') {
$('#' + prefix + 'mon_other').val(fortmon).change();
}
}
Is there a better way to write this?
Paul
-
- nuBuilder Team
- Posts: 4305
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Subform Calculations
Paul,
A bit shorter, (untested):
A bit shorter, (untested):
Code: Select all
function fillwhovalue() {
var whoid = $('#' + event.target.id).val();
var prefix = $(event.target).attr('data-nu-prefix');
var fortmon = $('#' + prefix + 'mon_fortamt').val();
$('#' + prefix + 'mon_self').val(whoid == 'S' ? fortmon : "0").change();
$('#' + prefix + 'mon_partner').val(whoid == 'P' ? fortmon : "0").change();
$('#' + prefix + 'mon_other').val(whoid == 'O' ? fortmon : "0").change();
}
-
- Posts: 249
- Joined: Sun Dec 06, 2020 6:50 am
- Location: Chennai, India, Singapore
Re: Subform Calculations
The database table (in the image in the first post) can be optimised by removing the Self, Partner, Other and Total columns and keeping the chosen value in the Amtl field alone or using an enum field to store the value directly.