Reputation: 2293
Is it possible to easily setup a select element in html have a entry for every number in a range (ie 1 to 30) without using 30 lines in my html document?
Upvotes: 0
Views: 68
Reputation: 640
if you aren't opposed to using PHP, PHP makes it super easy!
<select>
<?php
for($i = 1; $i<31; $i++){
echo "<option value='$i'>$i</option>";
}
?>
</select>
Upvotes: 1
Reputation: 565
No, but if your application is going to run on a few modern browsers, you could consider using the new HTML5 form controls, like range, or number.
<input type="number" name="foo" min="1" max="30">
<input type="range" name="bar" min="1" max="30">
The support for this can be found at http://caniuse.com/#feat=forms
Upvotes: 1