lets say i have a form text input with the value: 52.20
and i want to know the value before the decimal (20)
how can i achieve this?
Hi @mrbdrm,
Is the value before .20
always a 2-digit number, or can it vary?
yes its always 2 digits
Use the split filter, which will generate this code:
input1.value.split(".")
Then add to it [0]
so it becomes:
input1.value.split(".")[0]
This will always return the value before the decimal.
aha
so i need to convert it to string then split it.
Thanks @Teodor
No, if it is a form input, the value returned is always string. So just add the character to split it on:
yes correct. Thanks
is there a way to add the [0] from the formatter? or i just type it.
Yes, you can do that through the UI - select Split in the formatter, under Array select Top and enter 1 as a value:
This will return the first item of the split array:
Excellent
i see many more options of how to do things now.
you guys need to document all of this