javascript - Dynamically add number of options in a Dropdown list -
i have number value coming database. want display dropdown list based on count of number. example if number 5 need display 1-5 options in dropdown list. can 1 guide me on this?
thanks responses.
if database returns 5 , puts in variable "number" this:
<form> <select id="myid"></select> </form> <script> var number=5; var optionlist = ""; (var x=1; x<=number; x++) { optionlist += "<option>"+x+"</option>"; } $("select#myid").html(optionlist); </script>
Comments
Post a Comment