Forum Academy Marketplace Showcase Pricing Features

Display data in text field based off input

Hello - experimenting on pulling coupon codes from a database…

I have a text input box for the user to enter a coupon code. If the user enters a correct coupon in the input field I want to display the coupon discount in a text box next to it, if not some other text such as “Not a valid code”

I’m having trouble figuring out the dynamic input logic within the text box to display the discount, haven’t even got to how I will display the “Not a valid code”.

Data: Thing = Coupon Codes: Fields: Name (text) = Name of Coupon Discount (number) = dollar amt of Coupon

Logic: If Name = Input, then display Discount
Else display “Not a valid code”

Please help

Dynamic text = Search for Coupon Code:first item’s discount. On the search, add a constraint: name = input’s value.

This means that you’re searching all coupon code’s whose name = what is typed in the input, and you’re returning only the first result - a search returns a list - even if you know there is only 1 matching result, you still need to tell it to return 1 result, so that’s why “first item” (meaning first result of the list search)

Add a condition to the text element: When Search for Coupon Code:count is 0 (add the same name constraint to search as above) > change text = Not a valid code

This conditions means that you’re doing the same search and counting the number of results in the list. You want 1 result, but if it’s 0, then the text should change.

Try that out and see if that does what you need.


Gaby | Coaching Bubble

2 Likes

Hi Gaby - thank you for the quick response. Seems like part 1 is working, if the correct input is entered then it is returning the correct value in the text next to it. I put a few different codes in there and tested it - so far so good.

Couple other issues:

  1. When the page loads, seems like the text box is defaulting to the first value in the database:

  1. Not sure I did the conditional correct - “Not valid code” not working:

1: I’d make the text box not visible on page load and add a visibility condition: When input’s value is not empty, element is visible. That way it only shows when there’s something typed in.

2: Do you have the name constraint in that search for coupons? If you do and it’s still not showing the conditional text, try it another way… “When Search for Coupons (no restraint)'s Name does not contain input value” > change text.


Gaby | Coaching Bubble

1 Like

GOT IT!

  1. Hiding on page load wasn’t working for some reason, but I just changed conditional to (input value is empty), then unchecked the “This element is visible box”

  1. Didn’t know what you ment by name constraint at first, so I did not have this in, once I did it worked like a charm!

Thank you very much!

1 Like

Perfect! :slight_smile: