Reputation: 10964
If I have two select lists, can I populate them both with the same function? Somthing like this. This doesnt seem to be working though.
function populateSel(){
jQuery("#selectListOne, #selectListTwo")
.append('<option value=""></option>')
.append('<option value="Mr."></option>')
.append('<option value="Ms."></option>')
.append('<option value="Mrs."></option>')
.append('<option value="Dr."></option>')
.append('<option value="Prof."></option>')
}
Upvotes: 0
Views: 54
Reputation: 1422
function populateSel(){
jQuery("#selectListOne, #selectListTwo")
.append('<option value=""></option><option value="Mr."></option><option value="Ms."></option><option value="Mrs."></option><option value="Dr."></option><option value="Prof."></option>');
}
Thanks and regrads,
Upvotes: 0
Reputation: 388406
You have not specified the display label for the options, other than that it looks fine
jQuery("#selectListOne, #selectListTwo")
.append('<option value=""></option>')
.append('<option value="Mr.">Mr.</option>')
.append('<option value="Ms.">Ms.</option>')
.append('<option value="Mrs.">Mrs.</option>')
.append('<option value="Dr.">Dr.</option>')
.append('<option value="Prof.">Prof.</option>')
Demo: Fiddle
Upvotes: 2