F
Filament7mo ago
Osamz

Add data-attribute to options in select, do things using js, without xhr request

Hi, I have a Form, in which the user will select an option, based on this option, 2 Input fields should be updated, for example: Based on selected option the range of numeric values are allowed to user, user then writes in 1st Input the number of start, the 2nd Input will updated automatically based on Selected option.
Imagine I have visit program options, every visit plane has it's own number of days, (2 days, 5 days...etc), I want user to choose a plane, then input the day of start journey, 2nd Input will shows the last day of journey, basically calc: 2nd input = (1st input + days of selected visit plane).
Now, It's sent a request to server, to get visit plane by id, then get number of days, then set is using $set('field.days'), then when user writes an input, it sends another request to do basic calculations in 1st input field! While it's basically can be done as that: 1- inject data-days attribute in options 2- get the selected option with it's data-days value 3- onChange 1st input, fills the 2nd input. Is there any way to solve this? it's huge performance problem when network is weak / slow. code I wrote is refused to paste, so it's in attachments.
1 Reply
Osamz
OsamzOP7mo ago
Want results from more Discord servers?
Add your server