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){
          $('#'+elementId).find('option').remove().end()
            .append('<option value="-1">Select Creative Size</option>');

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

Popular posts from this blog

Android: where to run keytool command in android

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

Upload file on Google cloud storage using Java servlet on google app engine