Are you using any kind of javascript? Cause unless you want the page to reload, you need javascript.
Oct 5, 2020
4
Level 2
How to increment for loop in blade
I don't know if Im going about this the wrong way but I wanted a section of a form that allows the user to click a button that adds in extra fields should they want to include extra information. I was planning on doing this in a for loop such as below, but didn't know how to increment the counter when someone clicks the plus icon at the bottom. Any advice please? Would this need to be done in jquery?
{{ $n = 3 }}
@for ($i = 0; $i < $n; $i++)
<div class="row px-3 pb-2">
<select class="form-control registerInputBoxes dropdownSelect" name="condition[{{$i}}]" id="illness[{{$i}}]" style="width: 100%;">
@foreach ($allConditions as $condition)
<option value="{{ $condition->id }}">{{ $condition->condition }}</option>
@endforeach
</select>
<div class="col-12">
<p class="registerText mb-0">Time since diagosis</p>
</div>
<div class="col-4">
<label for="years" class="registerText pl-2">Years</label>
<input name="years" type="text" class="form-control w-25" style="float:left">
</div>
<div class="col-4">
<label for="years" class="registerText pl-2">Months</label>
<input name="months" type="text" class="form-control w-25" style="float:left">
</div>
<div class="col-4">
<label for="years" class="registerText pl-2">Days</label>
<input name="days" type="text" class="form-control w-25" style="float:left">
</div>
</div>
@endfor
</div>
<div class="text-right col-12">
<a href="#"><span class="plus" id="addAnotherIllness">+</span></a>
</div>
Please or to participate in this conversation.