Я задаю вам следующий вопрос, я должен убедиться, что в зависимости от выбора значения comboBox некоторые textBox / некоторые кнопки отключены .. глядя на форуме, я нашел это решение, но оно не работает ...
Включить текстовое поле формы HTML на основе значения раскрывающегося меню в той же форме?
Я прилагаю свой код ...
function changeTextBox() {
comp = document.getElementById('tipologiaMezzoSubAffidataria');
if(comp.value=='1 - Mezzi d opera')
document.getElementById('documentiRadioComando').disabled=true;
document.getElementById('realizzazioneBasamento').disabled=true;
document.getElementById('rischioFulminazione').disabled=true;
document.getElementById('denunciaMessaInServizioInail').disabled=true;
document.getElementById('verificaPeriodicaInail').disabled=true;
document.getElementById('ultimaVerificaPeriodicaASL').disabled=true;
document.getElementById('scadenzaUltimaVerificaMezzoSubAffidataria').disabled=true;
document.getElementById('verificaTrimestraleFuni').disabled=true;
document.getElementById('scadenzaUltimaVerificaFuniMezzoSubAffidataria').disabled=true;
else;
if(comp.value=='2 - Automezzi')
document.getElementById('certificatoConformitàCE').disabled=true;
document.getElementById('registroPeriodicheInterne').disabled=true;
document.getElementById('documentiRadioComando').disabled=true;
document.getElementById('realizzazioneBasamento').disabled=true;
document.getElementById('correttaEsecuzioneBasamento').disabled=true;
document.getElementById('rischioFulminazione').disabled=true;
document.getElementById('denunciaMessaInServizioInail').disabled=true;
document.getElementById('verificaPeriodicaInail').disabled=true;
document.getElementById('ultimaVerificaPeriodicaASL').disabled=true;
document.getElementById('scadenzaUltimaVerificaMezzoSubAffidataria').disabled=true;
document.getElementById('verificaTrimestraleFuni').disabled=true;
document.getElementById('scadenzaUltimaVerificaFuniMezzoSubAffidataria').disabled=true;
else;
if(comp.value=='4 - Attrezzature')
document.getElementById('annoCostruzioneMezzoSubAffidataria').disabled=true;
document.getElementById('certificatoConformitàCE').disabled=true;
document.getElementById('librettoDiUsoEManutenzione').disabled=true;
document.getElementById('librettoDiCircolazione').disabled=true;
document.getElementById('registroPeriodicheInterne').disabled=true;
document.getElementById('documentiRadioComando').disabled=true;
document.getElementById('realizzazioneBasamento').disabled=true;
document.getElementById('correttaEsecuzioneBasamento').disabled=true;
document.getElementById('rischioFulminazione').disabled=true;
document.getElementById('denunciaMessaInServizioInail').disabled=true;
document.getElementById('verificaPeriodicaInail').disabled=true;
document.getElementById('ultimaVerificaPeriodicaASL').disabled=true;
document.getElementById('scadenzaUltimaVerificaMezzoSubAffidataria').disabled=true;
document.getElementById('verificaTrimestraleFuni').disabled=true;
document.getElementById('scadenzaUltimaVerificaFuniMezzoSubAffidataria').disabled=true;
else;
}
<table cellspacing="0" cellpadding="0" id="table4" name="table4" class=" table order-list"> <tr>
<form method="POST" action='azioniContinua/inserisciMezzoSubAffidatario.php'>
<td style="vertical-align: middle;" align="center" class="coloreTdAttiva">SI/NO</br><input type="checkbox" class="chkView"/></td>
<td bgcolor="#DCDCDC"><input type="text" name="idMezzoAttrezzaturaSubAffidataria" id="idMezzoAttrezzaturaSubAffidataria" width="75px" class="form-control chkEdit larghezzaBase" enable></td>
<td width="144" bgcolor="#6DFD1E">AUTORIZZATO /<br>NON AUTORIZZATO / <br> DOCUMENTI IN SCADENZA</td>
<td>
<select name="tipologiaMezzoSubAffidataria" id="tipologiaMezzoSubAffidataria" class="form-control chkEdit larghezzaBase" enable onChange="changeTextBox();">
<option value="1 - Mezzi d opera">1 - Mezzi d opera</option>
<option value="2 - Automezzi">2 - Automezzi</option>
<option value="3 - Mezzi di sollevamento (All. VII del D-Lgs. 81/08)">3 - Mezzi di sollevamento (All. VII del D-Lgs. 81/08)</option>
<option value="4 - Attrezzature">4 - Attrezzature</option>
</select>
</td>
<td><input type="text" name="sottoTipologiaMezzoSubAffidataria" id="sottoTipologiaMezzoSubAffidataria" width="75px" class="form-control chkEdit larghezzaBase" enable></td>
<td><input type="text" name="marcaMezzoSubAffidataria" id="marcaMezzoSubAffidataria" width="75px" class="form-control chkEdit larghezzaBase" enable></td>
<td><input type="text" name="modelloMezzoSubAffidataria" id="modelloMezzoSubAffidataria" width="75px" class="form-control chkEdit larghezzaBase" enable></td>
<td><input type="text" name="matricolaMezzoSubAffidataria" id="matricolaMezzoSubAffidataria" width="75px" class="form-control chkEdit larghezzaBase" enable></td>
<td><input type="date" name="annoCostruzioneMezzoSubAffidataria" id="annoCostruzioneMezzoSubAffidataria" width="75px" class="form-control chkEdit larghezzaBase" enable></td>
<td class="coloreTdDrop" align="center">
<div id="drop_file_zone" ondrop="upload_file(event)" style=" width: 100%; border: 1px dashed black;" ondragover="return false">
<div id="drag_upload_file" >
<p>CARICA FILE<p/>
<input type="file" id="selectfile">
</div>
<input type="button" value="Seleziona File" id="certificatoConformitàCE" class="btn btn-success" onclick="file_explorer();">
</div>
</td><td class="coloreTdDrop" align="center">
<div id="drop_file_zone" ondrop="upload_file(event)" style=" width: 100%; border: 1px dashed black;" ondragover="return false">
<div id="drag_upload_file" >
<p>CARICA FILE<p/>
<input type="file" id="selectfile">
</div>
<input type="button" value="Seleziona File" id="librettoDiUsoEManutenzione" class="btn btn-success" onclick="file_explorer();">
</div>
</td>
<td class="coloreTdDrop" align="center">
<div id="drop_file_zone" ondrop="upload_file(event)" style=" width: 100%; border: 1px dashed black;" ondragover="return false">
<div id="drag_upload_file" >
<p>CARICA FILE<p/>
<input type="file" id="selectfile">
</div>
<input type="button" value="Seleziona File" id="librettoDiCircolazione" class="btn btn-success" onclick="file_explorer();">
</div>
</td>
<td class="coloreTdDrop" align="center">
<div id="drop_file_zone" ondrop="upload_file(event)" style=" width: 100%; border: 1px dashed black;" ondragover="return false">
<div id="drag_upload_file" >
<p>CARICA FILE<p/>
<input type="file" id="selectfile">
</div>
<input type="button" value="Seleziona File" id="registroPeriodicheInterne" class="btn btn-success" onclick="file_explorer();">
</div>
</td>
<td class="coloreTdDrop" align="center">
<div id="drop_file_zone" ondrop="upload_file(event)" style=" width: 100%; border: 1px dashed black;" ondragover="return false">
<div id="drag_upload_file" >
<p>CARICA FILE<p/>
<input type="file" id="selectfile">
</div>
<input type="button" value="Seleziona File" id="documentiRadioComando" class="btn btn-success" onclick="file_explorer();">
</div>
</td>
<td class="coloreTdDrop" align="center">
<div id="drop_file_zone" ondrop="upload_file(event)" style=" width: 100%; border: 1px dashed black;" ondragover="return false">
<div id="drag_upload_file" >
<p>CARICA FILE<p/>
<input type="file" id="selectfile">
</div>
<input type="button" value="Seleziona File" id="realizzazioneBasamento" class="btn btn-success" onclick="file_explorer();">
</div>
</td>
<td class="coloreTdDrop" align="center">
<div id="drop_file_zone" ondrop="upload_file(event)" style=" width: 100%; border: 1px dashed black;" ondragover="return false">
<div id="drag_upload_file" >
<p>CARICA FILE<p/>
<input type="file" id="selectfile">
</div>
<input type="button" value="Seleziona File" id="correttaEsecuzioneBasamento" class="btn btn-success" onclick="file_explorer();">
</div>
</td>
<td class="coloreTdDrop" align="center">
<div id="drop_file_zone" ondrop="upload_file(event)" style=" width: 100%; border: 1px dashed black;" ondragover="return false">
<div id="drag_upload_file" >
<p>CARICA FILE<p/>
<input type="file" id="selectfile">
</div>
<input type="button" value="Seleziona File" id="rischioFulminazione" class="btn btn-success" onclick="file_explorer();">
</div>
</td>
<td class="coloreTdDrop" align="center">
<div id="drop_file_zone" ondrop="upload_file(event)" style=" width: 100%; border: 1px dashed black;" ondragover="return false">
<div id="drag_upload_file" >
<p>CARICA FILE<p/>
<input type="file" id="selectfile">
</div>
<input type="button" value="Seleziona File" id="denunciaMessaInServizioInail" class="btn btn-success" onclick="file_explorer();">
</div>
</td>
<td class="coloreTdDrop" align="center">
<div id="drop_file_zone" ondrop="upload_file(event)" style=" width: 100%; border: 1px dashed black;" ondragover="return false">
<div id="drag_upload_file" >
<p>CARICA FILE<p/>
<input type="file" id="selectfile">
</div>
<input type="button" value="Seleziona File" id="verificaPeriodicaInail" class="btn btn-success" onclick="file_explorer();">
</div>
</td>
<td class="coloreTdDrop" align="center">
<div id="drop_file_zone" ondrop="upload_file(event)" style=" width: 100%; border: 1px dashed black;" ondragover="return false">
<div id="drag_upload_file" >
<p>CARICA FILE<p/>
<input type="file" id="selectfile">
</div>
<input type="button" value="Seleziona File" id="ultimaVerificaPeriodicaASL" class="btn btn-success" onclick="file_explorer();">
</div>
</td>
<td><b>Scadenza:<b><br/><input type="date" name="scadenzaUltimaVerificaMezzoSubAffidataria" id="scadenzaUltimaVerificaMezzoSubAffidataria" width="75px" class="form-control chkEdit larghezzaBase" enable></td>
<td class="coloreTdDrop" align="center">
<div id="drop_file_zone" ondrop="upload_file(event)" style=" width: 100%; border: 1px dashed black;" ondragover="return false">
<div id="drag_upload_file" >
<p>CARICA FILE<p/>
<input type="file" id="selectfile">
</div>
<input type="button" value="Seleziona File" id="verificaTrimestraleFuni" class="btn btn-success" onclick="file_explorer();">
</div>
</td>
<td><b>Scadenza:<b><br/><input type="date" name="scadenzaUltimaVerificaFuniMezzoSubAffidataria" id="scadenzaUltimaVerificaFuniMezzoSubAffidataria" width="75px" class="form-control chkEdit larghezzaBase" enable></td>
<td><b>Note:<b><br/><input type="text" name="note" id="note" width="75px" class="form-control chkEdit larghezzaBase" enable></td>
<td style=" border-style: none;"> <input type="text" name="fkIdAffidataria" id="fkIdAffidataria" width="75px" class="form-control chkEdit larghezzaBase" value="<?php echo $fkIdAffidataria?>"></td>
<td><input type="submit" name="submit" onclick="location.href='subAffidatario.php'" value="Salva MezzoDiTrasporto" class="btn btn-primary"/></td>
<td width="144" bgcolor="#6DFD1E">AUTORIZZATO /<br>
NON AUTORIZZATO</td>
<td><input type="submit" name="submit" onclick="location.href='subAffidatario.php'" value="Scarica BADGE" class="btn btn-primary"/></td>
<td>
<select name="dataDiAutorizzazione" id="dataDiAutorizzazione" class="form-control chkEdit larghezzaBase" enable>
<option value="Mezzi d'opera"></option>
</select>
</td>
</form>
</tr>
</table>
Я хочу, чтобы при изменении значения comboBox текстовые поля, которые я вставлял в скрипт, были отключены.Например, группа («1 - Опера Мецци») должна деактивировать следующие поля:
document.getElementById('documentiRadioComando').disabled=true;
document.getElementById('realizzazioneBasamento').disabled=true;
document.getElementById('rischioFulminazione').disabled=true;
document.getElementById('denunciaMessaInServizioInail').disabled=true;
document.getElementById('verificaPeriodicaInail').disabled=true;
document.getElementById('ultimaVerificaPeriodicaASL').disabled=true;
document.getElementById('scadenzaUltimaVerificaMezzoSubAffidataria').disabled=true;
document.getElementById('verificaTrimestraleFuni').disabled=true;
document.getElementById('scadenzaUltimaVerificaFuniMezzoSubAffidataria').disabled=true;
, но все остальное должно быть активным