Reputation: 1074
I have an HTML page (index.php) with a drop down menu that contain numbers 1-20. Is there a simpler way of adding the options to the drop down menu rather than just adding each manually like:
<option value=1>1</option>
...
<option value=20>20</option>
Upvotes: 1
Views: 1909
Reputation: 1042
As you already mention php in your tags, then using a for-loop when generating the web page would be possible:
for ($i = 1; $i<=20; $i++) {
echo '<option value="'.$i.'">'.$i.'</option>';
}
You should further think about spending some more quotes to the value attribute as in my code above.
Upvotes: 4