Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MohamedLamineAllal/38eb4fa77fff720f94e383ecce013717 to your computer and use it in GitHub Desktop.
Save MohamedLamineAllal/38eb4fa77fff720f94e383ecce013717 to your computer and use it in GitHub Desktop.
Boiler plate and example for jquery and pure js manipulation of select boxes
//example using select2 pluging (don't forget .trigger('change.select2'))
phoneCodeSelect.on('change', function () {
let countryName = $(this).find('option:selected').eq(0).text().replace(/\(.*\)/, '').trim().toUpperCase();
countrySelect.val(countryName).trigger('change.select2');;
// countrySelect.find('option:selected').prop('selected', false);
// countrySelect.find('option[value=' + $(this).find('option:selected').eq(0).text().replace(/\(.*\)/, '').trim().toUpperCase() + ']').prop('selected', true);
console.log('ssssssssssssssssssssssssssssssssssss');
console.log($(this).find('option:selected').eq(0).text().replace(/\(.*\)/, '').trim().toUpperCase());
console.log(countrySelect);
console.log('sssssssssssssssssssssssssssssssssssssss');
cc_bloodHound.clear();
cc_bloodHound.add(countriesCities[ucwords(countryName)]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment