Answer the question
In order to leave comments, you need to log in
How to display checkboxes in foreach in selection order?
I make the appointment of routes for drivers.
Here is the code:
@foreach ($storages as $storage)
<input type="checkbox" name="stock[{{ $storage->name }}]" class="custom-control-input">
@endforeach
foreach ($request->stock as $k=>$v) {
echo $k;
}
Answer the question
In order to leave comments, you need to log in
In the case of a regular form, the browser does not send information about the order in which the checkboxes are selected.
To do what you want, you need to fence on the Javascript front, which will keep track of the order of "clicking" on the checkboxes and somehow pass this information to the server. I will assume that in your case this means a significant reworking of the system.
Whether this "whistle" is worth such an effort is up to you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question