I am developing a laravel application with blade template.
When I click on the plus button, I get an additional field and when I click the minus button it gets removed properly and working fine.
However, I need to generate the additional section as a select option box, and this select option box has to show dynamic values.
<div class="RegSpLeft" id="affiliation">
<select>
@foreach($affiliation_array as $state_data)
<option>{{$state_data->value}}</option>
@endforeach
</select>
</div>
I want to display above array named affiliation_array
.
I'm using the following script to generate additional fields:
$('.affiliation_add a.pl').click(function(e) {
e.preventDefault();
$('#affiliation').append('<select><!--here i want to append my array as options --></select>');
num2++
});
$('.affiliation_add a.mi').click(function (e) {
e.preventDefault();
if ($('#affiliation select').length > 1) {
$('#affiliation').children().last().remove();
}
});
My button div is below,
<div class="RegSpRight affiliation_add">
<a href="#" class="pl"><img src="images/plus.png"></a>
<a href="#" class="mi"><img src="images/minus.png"></a>
</div>
Anybody please help me to solve this issue.