Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easy way to add drop down menu with 1 - 100 without doing 100 different options?

Tags:

html

forms

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

like image 472
GibsonFX Avatar asked Apr 13 '12 14:04

GibsonFX


People also ask

How do I create a custom dropdown?

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.

How more than one option can be selected in drop down?

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.


1 Answers

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

like image 149
Curtis Avatar answered Sep 18 '22 15:09

Curtis