I want to add options to a drop down list dynamically as per the integer value of a variable
this is my html code of dropdown list
<select class="inputreq" id="qty" name="qty"><option value="1">1</option></select>
Like below i am getting integer value at run time
var optioneValue = <%=getCurrentAttribute('item','custitem_max_qty_limit')%>
Suppose if optioneValue is 3 i want to display 3 options in dropdown list like this
<select class="inputreq" id="qty" name="qty">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
I have tried with javascript but its not working..I am new to this can we achieve this using jquery?
<script type="text/javascript">
var i = 1;
while ( i <= <%=getCurrentAttribute('item','custitem_max_qty_limit')%> ) {
var addSelectOption = document.getElementById('qty');
addSelectOption.options[i-1]= new Option(i,i);
i++; // Increment i
}
</script>