How to create input currency and perform calculation based on condition in Retool

I'm trying to create an input field that sets the value to "EUR" if the "currency_transaction" field is equal to "€". Additionally, I want this input field to perform a calculation by default. The calculation is simple: it should multiply the price (without currency) by the quantity. The two values, price and quantity, are manually entered into two input fields.

I apologize for my lack of programming knowledge, and I would greatly appreciate any help with the JavaScript code. Thank you in advance!

Hey Enrico! So you have a total of 3 inputs, correct? And one final Total value?

Would something like this work for you? How is your currency_transaction field being populated? In my example, I set it to a dropdown (Select component), but it doesn't have to be!

See attached app JSON if you want to poke around with my setup! You can import this JSON file by clicking Create new (home page) > From JSON. Quick docs on exporting/importing apps here.


Total-20calculator.json

Hi Victoria,

Very easy. Sorry to bother you for such stupid task.

Thank you very much.

E.

Enrico, no apologies needed whatsoever and definitely not a stupid task! Just glad I could help :slightly_smiling_face: Write back in anytime!