0
I don’t know if what I’m thinking is viable.
I have a form that dynamically creates several checkboxes with the dates of the month. However, I need when the user checks one of these dates to create two select tags, one referring to the time and the other to the minutes.
The way I tried to do, I created several selects and at the time of passing the request it came all values of selects even those I had not selected.
I don’t know if there can be any other solution for what I want. That actually just pass the pro request values of the dates I selected.
In the image below I did using Hidden in the fields and only enabling those that are marked however, as in the second image shows it passes all other values.
Looking at the image below you can notice what I don’t want.
Is there any way that it doesn’t happen?
The way I thought was to check some date he create those specific selects and only pass the required values in the request.
Follow my code for better understanding.
@foreach ($datas as $i=>$data)
<div class="col-md-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="{{$data}}" id="dt_adicional{{$i}}" name="dt_adicional[]" onclick="Mudarestado('tempo{{$i}}')">
<label class="form-check-label" for="dt_adicional{{$i}}">
{{$data}}
</label>
</div>
<div id="tempo{{$i}}" style="display:none">
<select class="form-control form-control-sm" id="horas{{$i}}" name="horas[]">
<option value="" selected>Horas</option>
@for($j=0; $j <= 120; $j++)
@if($j<10)
<option value="{{'00'.$j}}">{{'00'.$j}}</option>
@elseif($j<100)
<option value="{{'0'.$j}}">{{'0'.$j}}</option>
@else
<option value="{{$j}}">{{$j}}</option>
@endif
@endfor
</select>
<select class="form-control form-control-sm" id="minutos{{$i}}" name="minutos[]">
<option value="" selected>Min</option>
@for($k=0; $k <= 59; $k++)
@if($k<10)
<option value="{{'0'.$k}}">{{'0'.$k}}</option>
@else
<option value="{{$k}}">{{$k}}</option>
@endif
@endfor
</select>
</div>
</div>
@endforeach
I hope it’s clear what I want to do.
Thank you very much Sam, it worked perfectly.
– douglas pjuizfora