I have created two input cells on a page called “square2V” and “teamA”. Both are set to be numerical values.
When I multiply the two cells using the code below, it successfully multiplies the values and labels a button called “teamAScore” with this value.
it works but only combines the values instead of add the values. example: input1 = 12 input2 = 1
the above code returns the value 121 instead of 13 (12+1)
above vaguely referenced:
+num1 + +num2;
adding the unary + before is a quick solution.
@shaneicewilliams@mikemoynihan99 Hello, thank you so much for the calculation code! I was able to get my calculations to work properly thanks to both of you, but now how do you get the calculated value inserted into the database? I have tried to connect the element input to the database, and have tried to add a submit button, but the collection field is still empty. The calculations shows up on the page inside the correct element input box “fbTotal” , but even though its linked to the collection, it doesn’t export or show up. I need that number in there so I can display that total on a different page on my website. Please help and thank you!
Here’s my code:
$w.onReady( function () {
$w(‘#Calculate1’).onClick( function () {
console.log(“button has been pressed”)
$w(‘# fbTotal ‘).value = “” + (Number($w(’#dropdown1’).value) + Number($w(‘#dropdown2’).value) + Number($w(‘#dropdown3’).value) + Number($w(‘#dropdown4’).value) + Number($w(‘#dropdown5’).value) + Number($w(‘#dropdown6’).value) + Number($w(‘#dropdown7’).value));