I create a Javascript script which create option
in my html code, I have a problem when I want to put a loop in my variable.
The code show me this :
<select>
<option>undefined</option>
</select>
I have a table like
var event = ["Exercice1","Exercice2","Exercice3"];
Firstly, Here my variable :
iDiv = $('<select class="form-control">' +
event.forEach(function (eve) {
'<option>'+eve+'</option>'
})
+'</select>');
iBr = $('</br>');
iDiv.attr('id', 'select' + (currentDivsCount + i));
iDiv.attr('name', 'select' + (currentDivsCount + i));
iDiv.appendTo('table');
iBr.appendTo('table');
EDIT :
I created an other array which contains the ID of all Events and I want to put it each
var EventId = ["1","2","3"]
<option name="IdEvent">
I tried it :
iDiv = $('<select class="form-control"><option name="'+eventId.join()+'">'
+ eventlist.join("<option>")+ '</select>');
But I have this :
<option name="1,2,3,4,5,6">Exercice1</option>
Thank you for your helps
` and a ` – six fingered man Dec 07 '14 at 20:28