Answered by : defeated-dotterel-arkic42uqfbq
document.getElementById('my-select').addEventListener('change', function() { console.log('You selected: ', this.value);
});
Source : https://stackoverflow.com/questions/5416767/get-selected-value-text-from-select-on-change | Last Update : Thu, 21 May 20
Answered by : barisx
// Selecting the 3rd option (Demo 2)
document.querySelector('#mySelect').querySelector('option')[2].selected = 'selected'
Source : https://alvarotrigo.com/blog/javascript-select-option/ | Last Update : Sun, 31 Jul 22
Answered by : fancy-frog-1y2jrnhak0y7
const options = Array.from(select.options);
options.forEach((option, i) => { if (option.value === use_id) select.selectedIndex = i;
});
Source : | Last Update : Mon, 29 Jun 20
Answered by : hillary-oketcho
$("#select1").change(function() { if ($(this).data('options') === undefined) { /*Taking an array of all options-2 and kind of embedding it on the select1*/ $(this).data('options', $('#select2 option').clone()); } var id = $(this).val(); var options = $(this).data('options').filter('[value=' + id + ']'); $('#select2').html(options);
});
Source : https://stackoverflow.com/questions/10570904/use-jquery-to-change-a-second-select-list-based-on-the-first-select-list-option | Last Update : Fri, 24 Sep 21
Answered by : barisx
// Selecting the 3rd option (Demo 2)
const $select = document.querySelector('#mySelect');
$select.value = $select.querySelector('option')[2].value;
Source : https://alvarotrigo.com/blog/javascript-select-option/ | Last Update : Sun, 31 Jul 22
Answered by : successful-skunk-ymfo56vcu5v9
select.addEventListener('change', function);
Source : | Last Update : Fri, 28 May 21
Answered by : enzo-beauchamp
<script>
function val() { d = document.getElementById("select_id").value; alert(d);
}
</script>
<select onchange="val()" id="select_id">
Source : https://stackoverflow.com/questions/5416767/get-selected-value-text-from-select-on-change | Last Update : Mon, 17 Jul 23