Muzu
Muzu

Reputation: 71

Laravel 8 - Automatically update a form field when certain value is selected

I have a truck table and a postman table. Both tables have a one to one relationship. One truck has one postman, one postman has one truck.

Inside postman/create.blade.php file, there is an HTML form containing truck_number, postman_number, postman_name, and date_of_operation to be filled by the user.

the truck_number is presented in a dropdown list format, and the list get automatically updated everytime a truck_number is created from the truck table. inside the truck table, each of these truck_number has its own date_of_operation.

Therefore for the date_of_operation field inside postman/create.blade.php file, I want the value to get updated automatically within that same form when the user selects a particular truck_number associated with it.

Is it possible to do this in laravel without involving any form of ajax or json? How can I implement it correctly?.

Upvotes: 1

Views: 1013

Answers (1)

Azahar Alam
Azahar Alam

Reputation: 741

You cannot get the value until you have sent a request to server.You can use livewire, A fullstack framework associated with laravel. You can easily do the stuffs you are willing to do. Here is Documentation: https://laravel-livewire.com/docs/2.x/quickstart

Upvotes: 3

Related Questions