I am trying to populate a select drop down with the same amount of options as a number in a separate div.
For example, if a div has a value of “3” in it, i need to populate the select drop down with 3 options…. e.g.:
<select name="quantity">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
If the number in the div is changed to 6 – then it will populate the select with 6 options.
Any help much appreciated! Thanks.
Is this what you want?
http://jsfiddle.net/Sgqjg/
the html is:
and the script is:
Edit: appending and converting to int the text value of the div in each loop slows the proccess.