Problem with query and get input

i have little problem when use query result and get input element. My input value is texbox type number ‘inValue’ , but when get value element it convert to string. And when i try to use direct input from query it not contain any data from query insert to DB.

Hi Shiro,

Input always give you a string. Luckily, it is easy to convert it to a number.
In your case:

const inValue = parseInt($w('#input1').value, 10);

Hope this helps :slight_smile:

Liran.

Thank you Liran.
I did it.
But ‘sum’ variable can’t calculate because ‘values’ variable not contain output from query, can you help me fix this?

The problem you see is caused by the async nature of database access.

Whatever happens in the .then function happens after time wise from the code that is below the .then code.
e.g.

// this happens first 
wixData.query(..some collection..)
 .find()
 .then(() => { 
    // this happens later, after the code below
 })
 // this happens next

Just move the sum calculation into the .then function.

Yoav thank you for explain.
Now i can fix it.