如果您将内容包装在
form
元素中,那么您可以监听表单的更改并相应地切换 selectPresta.disabled
:
var form = document.getElementById('myform');
var radioExterne = document.getElementById('societeExterne');
var selectPresta = document.getElementById('selectPresta');
//listen for a change in the form
form.addEventListener("change", (event) => {
//does the value of form.radioSociete not match that of radioExterne?
selectPresta.disabled = !(form.radioSociete.value == radioExterne.value);
});
//trigger change on load to set initial state
form.dispatchEvent(new Event("change"));
<form id="myform">
<label><input id="societeInterne" name="radioSociete" type="radio" value="Interne" />Interne / </label>
<label><input id="societeExterne" name="radioSociete" type="radio" value="Externe" />Externe - </label>
<label for="PrestataireStit"> Préciser le STIT </label>
<ol>
<li style="list-style-type: disc">
<select id="selectPresta">
<option value='GROUPE presta' name='Societe presta'>presta</option>
<option value='GROUPE presta' name='Societe presta'>presta</option>
<option value='GROUPE presta' name='Societe presta'>presta</option>
</select>
</li>
</ol>
</form>