load dropdown list from comma separated string - Javascript jQuery

Javascript examples for jQuery:Select Dropdown

Description

load dropdown list from comma separated string

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from   w ww.j  av  a  2s .c om
var result = 'a,b,c,d';
$('.ddlASN').html($.map(result.split(','), function(item) {
  return $('<option></option>').val(item).html(item)[0].outerHTML
}).join(''));
    });

      </script> 
 </head> 
 <body> 
  <select class="ddlASN"> </select>  
 </body>
</html>

Related Tutorials