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

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -