Ray
Ray

Reputation: 6115

html select - range of 0-10

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

Answers (3)

Kristian
Kristian

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

Dryvenn
Dryvenn

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

Zoltan Toth
Zoltan Toth

Reputation: 47687

Unfortunately you have to repeat the code if you use just HTML

Upvotes: 4

Related Questions