I have 2 selects, and I want to make that when one of the select is with an option other than empty, the other select goes into disable.
Follow my code:
<script type="text/javascript">
function handleSelect() {
if (this.value == '30') {
document.getElementById('agente_id').disabled = true;
} else {
document.getElementById('agente_id').disabled = false;
}
}
</script>
<div class='container'>
<form method="get" action="/financeiro/gerar_relatorios">
<div class='panel panel-primary'>
<div class='panel-heading'><B>FILTRAR COMISSÕES POR PERÍODO</b></div>
<div class='panel-body'>
<div class='row'>
<div class='col-xs-6'>
<?= $this->Form->input('data_inicio', array('class' => 'form-control mask_date','value'=> @$_GET['data']['data_inicio'])); ?>
</div>
<div class='col-xs-6'>
<?= $this->Form->input('data_fim', array('class' => 'form-control mask_date','value'=> @$_GET['data']['data_fim'])); ?>
</div>
</div>
<div class='row'>
<div class='col-xs-6'>
<?= $this->Form->input('colaborador_id', array('class' => 'form-control','empty'=>'Filtrar todos colaboradores','value'=> @$_GET['data']['colaborador_id'])); ?>
</div>
<div class='col-xs-6'>
<?= $this->Form->input('agente_id', array('class' => 'form-control','empty'=>'Filtrar todos agentes','value'=> @$_GET['data']['agente_id'])); ?>
</div>
</div>
<div class='row'>
<div class='col-xs-6'>
<?= $this->Form->input('compra', array('class' => 'form-control','placeholder' => 'Filtre pelo número da compra','value'=> @$_GET['data']['compra'])); ?>
</div>
</div>
</div>
<div class='panel-footer'>
<?= $this->Form->submit('Filtrar', array('class' => 'btn btn-info')); ?>
</div>
</div>
</form>
My question is, how to instantiate this js function in select?