Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

populate dropdown using jquery from database

Use a string to store your option, and then append it to the select tag. Then, please check that data is there in the val.

$.getJSON("get-data.php?dat=driver",function(data){
    var stringToAppend = "";
    $.each(data,function(key,val) {

       stringToAppend += "<option value='" + val.id + "'>" + val.id + "</option>";

    });

    $("#night_Shift_text").html(stringToAppend);
});
 
PREVIOUS NEXT
Tagged: #populate #dropdown #jquery #database
ADD COMMENT
Topic
Name
7+6 =