PricingBlog

Set variable on change of option in Select Element

  • anish99-1268599002858000476

    Anish

    1 year ago

    This is my first shot at building with Toddle Dev. Trying to build a currency rate calculator.

    I have two separate path from the same API (Currency List, Currency Rate) that is turned into an array(Currency). Currency List consist of meta data of currencies and Currency Rate fetches live exchange rates.

    Top most block has base currency selection where user can select desired currency. ‘Select’ element options are generated from ‘currency’ array using repeat. Currency symbol text is bind to a variable 'base symbol', currency name text is bind to variable 'base currency name'. I want to change currency symbol and currency name as well when currency select option changes. What could be the logic applied here?
    1268599003474559108-Screenshot_2024-08-01_at_19.07.29.png
  • andreasmoller-1268604742045667349

    Andreas Møller

    1 year ago

    You can set the other variables at the same time you set the base currency
  • andreasmoller-1268605151728631929

    Andreas Møller

    1 year ago

    If your other variables can be computed from base currency it is better to use a formula instead of a variable. That way you guarantee that the data cannot get out of sync
    👏1
  • Does that make sense?
  • anish99-1268637756008042527

    Anish

    1 year ago

    Thanks @Andreas Møller ! Totally makes sense, Worked perfectly.
    1268637755932409909-Variable_change_on_input.png
  • andreasmoller-1268646507612209203

    Andreas Møller

    1 year ago

    Nice!
    Instead of Get and Find index you Can also just use Find
  • anish99-1269561391191425034

    Anish

    1 year ago

    Thanks @Andreas Møller