Show price when item selected.
Hey guys can anyone recommend an approach i should take. I want to show the cost field value for an item when i select that item in a select option next to it. So when you select a item you see its cost pop up next to it.
Here is the current relevant step in the from wizard
```
16 Replies
@josef tagging you as requested thank you for offering to help.
So what exactly doesn't work? Does it update the cost according to the selected item?
And which one is the select that should update the cost?
$set
and your fields aren't live()
The final formula i am trying to achieve is volume + (selected materials) pricePermm3 * by quantity to get the final price.
You mean i should add an addition to this for example?
onblur means when users removes focus from input
check docs about reactivity
Right now i can just pull the volume and perform math operators on it and have that value be shown in a disabled textinput.
Yes that was my strategy to know when they had finished entering their values and i could then perform the operations using
Depends. using
onBlur
is totally fine if you want the calculation to only happen after the user shifts focus away from the field
I'm still not sure on what exactly does not work as you want it to
You got select fields that are reactive and the field where you display the calculation resultRight now what i think the first problem is i am unable to get the pricePermm3 value from the selected material when it is chosen from the dropdown. I would like to save that as a variable so i can use it in the overall price calculation
If you calculation depends on multiple values, I'd move the calculation itself to the field that displays it, getting the requird values from the other fields using
$get
, then, when one of the fields changes, the cost field updates itself
just have live()
(with or without onBlur
) on the required fields, and move all the calculation into the cost field
probably using somethign like
Thank you so much @josef I will experiment and post any additional challenges in this thread.
I will have to also figure out how to query the pricePermm depending on what material is selected.
Just this and my file downloading issue and i can tidy everything up for the submission. Then i can actually experment without this crazy time presure and actually have some fun with it.
is the intention that i use like this?
Just use visible() on the textinput
I don't understand
This is for v2
So replace reactive with live
You can swap the disabled with visible if you like to hide it
I am not trying to hide it im just trying to have it update as you change your selections for material, there is also a priority checkbox that is on another part of the form that i will need to add a static amount too this for also
Or am i misunderstanding you?
Na, you got it. Ignore that, if you don't want to hide the field yet. Just get it working first
i would rather them see it so they can see the impact of their choice on the price.