Append option into a select using jquery

You can use jquery to append data from select from a array of data. See the java script function where you can pass the dataArray like dataArray=["A","B"] and elementId , means the id attribute of your select element;

function appendDataToSelectDropDown(dataArray,elementId){
      if(dataArray !=null && dataArray.length>0){
            .append('<option value="-1">Select Creative Size</option>');

          $.each(dataArray, function( index, value ) {   
                $('#'+elementId).append(new Option(value, value));


Popular posts from this blog

Can not connect to git using ssh (Permissions 0644 for '/root/.ssh/id_rsa' are too open.

Struts 2 - struts tag with boolean property