2nd time searching for how to refresh select box using javascript / jquery. I’ve found the solution previously but the code is hidden somewhere else… grrr… Just a note for myself to refer how to refresh select box using javascript / jquery. Hope this helps u too!
To refresh select box using jQuery, refer to the code below:-
Advertisements
// Assuming there is a select box with ID = myselectbox
// this will clear all select box item
$('#myselectbox').children().remove().end();
var s = document.getElementById('myselectbox');
// add item to select box
s.options[s.options.length] = new Option('', '');
s.options[s.options.length] = new Option('Label 1 here', 'value 1 here');
s.options[s.options.length] = new Option('Label 2 here', 'value 2 here');
Share this with your friends:-