Set Var with condition when changed

I don’t know how to set with Wappler
I am setting variables, when the value of some fields of the form changes and everything works perfectly.
But for a variable I want to modify with conditions
Example:
If Var A == “text product1”
-> then Var B == “result AAA”
If Var A == “text product2”
-> then Var B == “BBB result”

You could use a ternary expression in the variable:

e.g. for Var B

dmx-bind:value="varA.value == 'product1' ? 'result1' : 'result2'"

You can nest several together if it is more complex than just 2 options:

dmx-bind:value="varA.value == 'product1' ? 'result1' : varA.value == 'product2' ? 'result2' : varA.value == 'product3' ? 'result3' : 'result4'"

Thank you but it doesn't work for me
Maybe the setting is wrong
I'll try again tomorrow

Schermata 2022-07-05 alle 00.27.12

You would only enter:
varA.value == 'product1' ? 'result1' : 'result2'
In that code box the code that includes the dmx-bind is what you can copy and paste directly into the pages html code

It does not work yet
Maybe I took the wrong road and I need to explain my need better
In a page I have a Select input that offers only two choice options (Result1 and Result2)

Then I have input text which should populate with the opposite of the choice made in the select.
If Select = Result1 -> input Text = Result2
If Select = Result2 -> input Text = Result1

Maybe I have to sort it out some other way?

Thanks to your suggestions I was able to solve the problem.
Now when the value of a select changes (with only two options available) the destination field takes on the opposite value, as I wanted.
Just a little annoying problem that I can’t avoid
In fact, if the value of the select is null, the destination field should also be null; instead it takes the result1

However, I still have some problems due to the fact that I need a choice to be made in the second select too, to activate some actions on changed.
I could fix it, but I don’t know if it’s possible, much more simply by disabling or hiding the unwanted option in the second Select

Select 1 Option A / Option B
Select 2 Option A / Option B
If Select 1 == Option A —> in Select 2 Option A disabled or hidden
If Select 1 == Option B —> in Select 2 Option B disabled or hidden
Some idea?

Problem solved with javascript