Reputation: 6115
If I want to give a choice of 0-10 in five different selects, is there HTML code for this (non HTML5) that allows me to not repeat the choices for each of the five selects, or do I have to repeat this code?
Thanks
Upvotes: 2
Views: 6383
Reputation: 21830
really, consider using JS for that.
some example html:
<select id="someSelect">
</select>
your script:
var options = "";
for(var i = 1; i<11; i++ ) {
options += "<option value="+i+">+i+</option>";
//EDIT summary:there was no string concatanation
}
then just set the html value of your select equal to that variable:
document.getElementById('someSelect').innerHTML = options;
or if you were using jquery:
$('#someSelect').html( options );
Upvotes: 4
Reputation: 11
You can use angularjs and its directive "ng-repeat" for that.
<div ng-repeat="choice in choices">
<p>something with {{choice}}</p>
</div>
Upvotes: 1
Reputation: 47687
Unfortunately you have to repeat the code if you use just HTML
Upvotes: 4