Logic in Wappler

Hi!
I’m a new at Wappler.
How do I do this in Wappler?

I have variables
man, tis, ons, tor, fri, lor, sun
and a tempVariable and a query parameter.

Want to do this …

If (tempVariable == 1) {man = queryParameter}

If (tempVariable == 2) {tis = queryParameter}

If (tempVariable == 3) {ons = queryParameter}
and so on…

How do I do this?
Is it even possible?

1 Like

Hello,
First you need to setup your query parameter, by selecting App and click the Define Query Params button. Once you define it there, it becomes available in the data picker on the page.

In order to add a value to a variable, use the value option available when you select it in the App Structure. You can enter:

tempVariable.value == 1 ? query.yourParameter : ''

as an expression for your man variable. This will set the query parameter value if your temp variable value equals 1, otherwise it will be empty.

1 Like

Okej, but if i don´t want it to be empty if it false?
I like it too keep its value if it false.

Then using flows is perfect for you. Create a flow with multiple conditions like:


So add a condition for each of the variables, which value you want to control.

then you can run the flow on page load or when the tempVar value changes.

1 Like

Hmm… should try to explain how I want to work, maybe you have a better suggestion. I have a list of the 7 weekdays available. For each weekday, a dish is randomized from a mysql database. The user can click on the dish and then a new dish is generated. All this works. When generating button is clicked, the current weekday is saved to a cookie called man (monday). The rest of the weekdays have their own cookies.

If the user wants to select a dish from the entire database, the user clicks on a list that knows which weekday he clicked on and which dish he also chose.

Then it returns a call index.php?weekday=man&food=swedish meatballs

I want to save down there current querystring food to the cookie man, IF it is the weekday monday he clicked on. I do NOT want the cookie to be emptied because I need it.

Had I done this in javascript this would have looked like this and put this in a separate .js file and loaded it in body onload ().

Have tried this, but did not make it work.

If (query.veckodag == 1) {cookie.man = query.food}

If (query.veckodag == 2) {cookie.tis = query.food}

If (query.veckoday == 3) {cookie.ons = query.food}

If (query.veckodag == 4) {cookie.tor = query.food}

If (query.veckodag == 5) {cookie.fre = query.food}

If (query.veckodag == 6) {cookie.lor = query.food}

If (query.veckodag == 7) {cookie.son = query.food}

PS. The code is not correct, only for explanatory reasons

Hope you understand how I think
I’m from Sweden so my english is not perfect :slight_smile:

WOW! Thanks for the tip on Flow, didn’t know it existed. Have only had Wappler for a few days. Worked absolutely perfect !!

1 Like