Skip to main content
Solved

Else condition is not getting executed in the prototype


Noyal

Hello community,

I’ve been experimenting with a conditional prototype and encountered an issue where my “else” statement is not being executed. I suspect I might be missing a step.

Here’s my scenario: I have a checkbox component. When checked, the pricing should increase by $20, and when unchecked, the $20 should be deducted.

Here are the steps I followed:

  1. Created a boolean variable for the checkbox.
  2. Created a number variable for the pricing.

When I check the checkbox, the conditional prototype works as expected, and the pricing increases by $20. However, when I uncheck the checkbox, the “else” statement does not execute.

Any help resolving this issue would be greatly appreciated.

Thank you!

Adding the interaction for reference: Else condition.mov - Google Drive

Best answer by Vishal_Ramawat

Can you modify the checkbox component?

View original
This topic has been closed for replies.

7 replies

Vishal_Ramawat

Can you modify the checkbox component?


Noyal
  • Author
  • 4 replies
  • July 5, 2024

Hey RHJ,

Thanks for sharing your thoughts. I tested the prototype step-by-step but still can’t figure out what’s going wrong. I appreciate you taking the time to answer my query.

Thanks again!


Noyal
  • Author
  • 4 replies
  • July 5, 2024

Hey Vishal,

Thanks so much! 🙂

I was really struggling with conditional looping and variables for hours. I can’t believe I made it so complicated. Your solution is so simple. Instead of adding the prototype at the component level, I was trying to do it at the instance level. I was worried I might waste my whole day trying to find a solution, but you made it easy.

Thanks again for taking the time to add those screenshots. They really help! 🙂


Vishal_Ramawat

Glad to hear it worked. Please do mark the answer as solution 🙂


Noyal
  • Author
  • 4 replies
  • July 5, 2024

Hello @Vishal_Ramawat,

Sorry to bother you again!

I have another query on top of my previous question. The click-based price adjustments are working perfectly now, but I need to add an additional condition.

Let’s say I’ve duplicated the checkbox instance a few times. I want a CTA to be enabled if any one of the checkboxes is checked, and only when all the checkboxes are unchecked should the CTA return to a disabled state. I tried adding a condition to enable and disable the CTA on top of adjusting the pricing, but it doesn’t work as expected when I have more than one checkbox.

How do I solve this?

Adding the interaction for reference: Else with condition.mov - Google Drive


Vishal_Ramawat

For this, you wont be able to do with component.
You’ll have to have separate checkboxes with each having it’s own variable that will give you checked or not.
Checkbox 1 = varCB1, Checkbox 2 = varCB2, Checkbox 3= varCB4
varCB1 = varCB2 = varCB3 = “Unchecked”.
So on Click event of each, you toggle the state to Checked/ Unchecked, AND when you are setting it unchecked, you check for other checkbox variables, if all varCB1 = varCB2 = varCB3 = “Unchecked” then you enable the CTA.


Noyal
  • Author
  • 4 replies
  • July 5, 2024

Yes, it works without components. However, when I convert them into components, I’m unable to achieve the desired effect. Without components, it feels like I’m just creating multiple checkboxes/pages for interaction.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings