I have a javascript function that makes a Web Api call and returns the data. I am trying to get the 2 properties of the value returned but am having issues with how to assign the quotes.
function populateNext(nextDD, nextLbl, apiCall, nextDDText, nextDDVal) {
$.getJSON("api/" + apiCall + "/" + facility_id)
.done(function (data) {
var s = '<option value="-1"></option>';
$.each(data, function (key, val) {
s += '<option value="' + val.plan_code + '">' + val.plan_code + '</option>';
});
$("#" + nextDD).html(s);
});
}
The first below line works but how would I change it so that it accepts the values passed in from the function (nextDDVal and nextDDText)?
Works:
s += '<option value="' + val.plan_code + '">' + val.plan_code + '</option>';
What I'm trying to make work:
s += '<option value="' + val. + nextDDVal + '">' + val. + nextDDText + '</option>';