Page 2 of 3

Re: Decimal comma & nuDebug() Entries

Posted: Fri May 25, 2018 12:01 pm
by toms
Not in the subform but you can add it in the parent form.

Re: Decimal comma & nuDebug() Entries

Posted: Fri May 25, 2018 12:15 pm
by ahernandez
I tried this but doesn't works...

var x = document.getElementsByClassName("input_nuNumber nuNumber nuEdit");
var i;
for (i = 0; i < x.length; i++) {
$fieldname = x.id;
$($fieldname).attr('onchange','').on('blur', function(event) {
$(this).val($('#nuNumber').val().replace(',','.'));
nuChange(event);
});
}

Re: Decimal comma & nuDebug() Entries

Posted: Fri May 25, 2018 1:01 pm
by toms
It's easier with the nuSubformObject() function:

Code: Select all

function fixCommas(frm, field)
var sf = nuSubformObject(frm);
for (var i = 0; i < sf.rows.length; i++) {
    $('#' + frm + nuPad3(i) + field).attr('onchange', '').on('blur', function (event) {
        $(this).val($(this).val().replace(',', '.'));
        nuChange(event);
    });
}
Example:

Code: Select all

fixCommas('yoursubformid','youfieldid');

Re: Decimal comma & nuDebug() Entries

Posted: Fri May 25, 2018 7:26 pm
by ahernandez
I'm trying to understand...

This code is to enter in JS code of the Form?

function fixCommas(frm, field)
var sf = nuSubformObject(frm);
for (var i = 0; i < sf.rows.length; i++) {
$('#' + frm + nuPad3(i) + field).attr('onchange', '').on('blur', function (event) {
$(this).val($(this).val().replace(',', '.'));
nuChange(event);
});
}

and where I have to put the call to this function?

Re: Decimal comma & nuDebug() Entries

Posted: Fri May 25, 2018 7:33 pm
by ahernandez
What is this function??
nuPad3(i)

I can't find it in the documentation...

Re: Decimal comma & nuDebug() Entries

Posted: Fri May 25, 2018 8:17 pm
by ahernandez
Ok

Forget my last post...

I have put this code in JS Code of the Form

function fixCommas(frm, field)
var sf = nuSubformObject(frm);
for (var i = 0; i < sf.rows.length; i++) {
$('#' + frm + nuPad3(i) + field).attr('onchange', '').on('blur', function (event) {
$(this).val($(this).val().replace(',', '.'));
nuChange(event);
});
}

And this one in the 'onchange' event of the subform field
fixCommas('yoursubformid','youfieldid');

It executes the function fixCommas getting the right values for frm, field and sf variables, but it doesn't change the field value replacing the '.' by ','

I apologize for the inconvenience toms.

Re: Decimal comma & nuDebug() Entries

Posted: Fri May 25, 2018 8:27 pm
by ahernandez
Hello!!

Again forget everything I said.
I had mis indicated the name of the subform.
Now it works correctly.

I'm very grateful toms!

Re: Decimal comma & nuDebug() Entries

Posted: Sat May 26, 2018 11:33 am
by toms
Don't forget to apply the fix if new rows are added.

Re: Decimal comma & nuDebug() Entries

Posted: Sat May 26, 2018 4:58 pm
by ahernandez
I have made these changes on subform field... including two events, onchange & onblur
Captura de pantalla 2018-05-26 a las 16.55.26.png
is it ok?

Re: Decimal comma & nuDebug() Entries

Posted: Sat May 26, 2018 5:07 pm
by ahernandez
Excuse me..

These are the changes I've made.. but I think this is not the best place to put it, isn't it?

The function fixCommas() is in the Form JS Code.
Captura de pantalla 2018-05-26 a las 17.06.03.png