Redirecting user on form submission

Let’s say we have the following elements
#Dropdown1 and #Dropdown2 with the following labels and values.


Now on submission I want add the value of #dropdown1 + value of #dropdown2 and direct users

wixLocation.to("/<sum>"); //<sum> is a dynamic page

I’ve tried some coding but not sucess.

Hi Carlos,

$w(‘#dropdown’).value returns a string, and it is not possible to do math on strings.
To fix the issue wrap the result in Number() to force it to become a number.

For example:

let firstNum = Number($w('#dropdown').value) //2
let secondNum = Number($w('#dropdown2').value) //3
let sum = firstNum + secondNum; //sum = 5

Small tip: Some elements, such as a text, will not accept a number as a value.
To fix this, you can wrap a number with String() similar to the method shown above.