<div class="group">
<label class="primary">
<input data-select="3" type="button">Кнопка 1</label>
<label class="primary">
<input data-select="4" type="button">Кнопка 2</label>
</div>
<select id="select">
<option value="1">Выбор пункта 1</option>
<option value="2">Выбор пункта 2</option>
<option value="3">Выбор пункта 3</option>
<option value="4">Выбор пункта 4</option>
<option value="5">Выбор пункта 5</option>
<option value="6" checked >Выбор пункта 6</option>
</select>
<script type="text/javascript">
document.getElementsByClassName('group')[0].addEventListener('click', function(evt) {
var elem = evt.target;
if (elem.hasAttribute('data-select')) {
let select = document.getElementById('select');
select.value = elem.getAttribute('data-select');
let options = select.getElementsByTagName('option');
Array.from(options, (option, i) => options[i].disabled = (option.value !== select.value ? true : false));
var elem = document.getElementById('select');
var event = new Event('change');
elem.dispatchEvent(event);
}
}, false);
</script>
|