Hello, I am a beginner at laravel and followed some tutorials and created something, but I need some help regarding finalising it,
I created a flow where
sections have many years > years have many months > months have many days
so at the time of days, create / edit
I am not able to find which month I am selecting because I called all months inside the dropdown,
so I found a solution is a dependent dropdown in which the user first has to select a section and then a year and then month which only belongs to year which is selected by user
how can I do it.
note- use of jquery is preferred but optional.
Thank you so much for your attention and participation.
You have to write controller methods that return the datas you need (section, year, month, ...).
First you load the sections at the same time the page loads.
When a section is selected, you load the years via jquery/ajax calling your controller method to get years.
And when a year is selected, you load the months via jquery/ajax calling your controller method to get months.
Select 1 : sections
You set an event on the selection of a section.
$('your_sections_select').on('change', function(e) {
// Here you can retrieve the id of the selected section if needed
$section_id = e.target.value;
// Here you get the needed years
// If you need to send the section_id, you can either add this value as an URL parameter, or using post instead of get
$.get( "route_to_get_the_years", function(data) {
// Here you fill the options of your years select using the data retrieved
$("your_years_select")...
// And here you log some information to confirm the action is ok
console.log("Load was performed.");
});
});
And you can apply the same logic when you select a year to display the months list.