How to add options to a select from an array with jQuery? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to add options to a select from an array with jQuery?

danielm77danielm77 USAPosts: 72Member

Please let me know the best way to add values from a JSON object to a select box using JQuery.

Tagged:

Comments

  • DavidMDavidM USAPosts: 342Member
    $.each(jsonObjectName, function(key, value) {   
         $('#yourSelectID')
             .append($("<option></option>")
             .attr("value",key)
             .text(value)); 
    });
    
Sign In or Register to comment.