Solved: Code for comparison of Text value and Number value is not working

Hi,

I created a Code which compares the value of a text field with the value of a inputbox field. The Code seems just to care about the first value number and that is why the outcome is sometimes incorrect.

E.g.: Works for:


→ 750>70 → Rabatt = 0, as there are not enough Points owned (see Text value)


→ 65<70 work as enough points are available → Rabatt = 0,65€

E.g. Code is not working:


→ 500>70 → Rabatt =5€ which is not correct, as not enough Points are owned

My Code looks like this:
export function Umrechner_click ( event ) {
if (( $w ( ‘#PunkteEingabe’ ). value ) <= $w ( ‘#PunkteKonto’ ). text ) {
let PunkteEingabe = Number($w ( ‘#PunkteEingabe’ ). value );
$w ( ‘#Rabattwert’ ). text = ( PunkteEingabe / 100 ). toString ();
}
else if (( $w ( ‘#PunkteEingabe’ ). value ) > $w ( ‘#PunkteKonto’ ). text ) {
console . log ( “Maximalwert überschritten” );
}
}

Hint: Even if I change the Text field into an Inputfield and compare .value with .value, I get the same result.
BTW: The Text field value is taken from my dataset and there it is marked as #Number.

Any ideas?
Thank you

I found a solution. For anybody that may search for the same - Thats how I solved it:

Basically you need to make sure, that Text field and also Inputfield value is a number.
Otherwise you will not the wished result.