Input statement not responding

I have tried to take two user inputs and multiply them together using a simple code:

Back-end looks like this:


export function multiply(factor1, factor2) {
return factor1 * factor2;
}


Simply multiplying to input statements

The front-end looks like this:


import {multiply} from ‘backend/SimpleTestFunc’;

$w.onReady( function () {

});

export function button1_click(event) {
multiply($w(“#input1”),$w(“#input2”))
.then(product => {
console.log(product);
})
. catch (error => {
console.log(error);
});
}

It is in this part i think the problem is:
multiply($w(“#input1”),$w(“#input2”))


I have tried to change the type of input of #input1 and #input2 to number and text, though it have not worked.

Then I manually set numbers in the multipy func it works, but using the above code it simply returns null.

I have tested the buttom1_click(event) and it works.

That´s wrong

thank you

  • Erik

You need to get the value of each input field:

multiply($w(" #input1 “).value,$w(” #input2 ").value)

Thank you !

In the same piece of code, how do I display the data in a text box?
I have tried to look at different youtube clips to find a solution but have not been successful. What seems to be the issue, and do you have a tutorial I can work my way though?

import {multiply} from ‘backend/SimpleTestFunc’;

$w.onReady( function () {

});

export function button1_click(event) {
multiply($w(“#input1”).value,$w(“#input2”).value)
.then(product => {
$w(“#text1”).text = product
})
. catch (error => {
console.log(error);
});
}

The above does not generate any error in preview, though not displaying the result. Unfortunately.

Thank you.