I’m trying to add two variables together.
I figured Wappler was getting confused when adding values straight out of the database, so I’ve made variables that have the same value.
But, Wappler does not want to add them together for some reason.
Is this correct?
The code:
So you can see the output…
Each variable on its own is outputting the correct value.
When added together it doesn’t work.
The issue with using values directly from the db… in the past when I’ve encountered some weird issue that I couldn’t solve, if I dump the value to a variable, instead of working directly from the db value, it has worked.
I couldn’t get this to work, so I dumped it into a variable first.
I believe this is typing dmx.app.data into the console in browser dev tools it will give you a object tree with all the variables values etc so you can see what the value is and wether its a number or string etc.
On a side note I haven’t used the tonumber formatter much so this is just a idea, but I see your applying it to both values what if one is already a number? not sure how Wappler would handle this could be nothing just wondering if that would throw some error
Well one of the values is a number and the other is a string. You can’t convert a number value to a number, the tonumber formatter should not be applied to it.
Okay, so when I remove the .toNumber from that one it adds up correctly.
Same would apply to the originals.
rte_FA_ListALLExpenses.sc_ListALLExpenses.data.query_AllExpenses_Finance.limit was a number.
But, id_select_limitNumberOfExpensesListed.selectedValue was not.
edit: I incorrectly assumed the value from a select box would be a number.
This is not the case. toNumber() only works with strings in its current form. What can work is multiplying by 1 which then always gives the answer as a number e.g. routetosomenumber.value*1
It would, however, be good to extend the toNumber formatter to return a number if it already was one.