I was just wondering if there was a simple shortcut to add options to a dropdown menu for the numbers 1 to 100 instead of having to do the following:
<option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option>
etc. all the way to 100?
Thanks
Example Explained HTML) Use any element to open the dropdown content, e.g. a <span>, or a <button> element. Use a container element (like <div>) to create the dropdown content and add whatever you want inside of it. Wrap a <div> element around the elements to position the dropdown content correctly with CSS.
To select multiple options in a drop-down list, use the multiple properties. It allows you to select more than one option while pressing CTRL key.
Not with plain HTML I'm afraid.
You could use some jQuery to do this though:
$(function(){ var $select = $(".1-100"); for (i=1;i<=100;i++){ $select.append($('<option></option>').val(i).html(i)) } });
-- SEE DEMO --
You can download jQuery here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With