1
I have 2 selects, and want to make sure that when one of the select is with a different empty option, the other select enter disable.
Follows 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 function js in select?
I did it this way, but when I select the option value is 30, select
agente_id
, remains qualified.– Michel Henriq
ok, but he is entering the handleSelect function ? if he is seeing what comes in this.value and post here
– Thiago Friedman
I’m trying to debug in firebug, but the console shows nothing.
– Michel Henriq
put a console.log inside the function before the condition
– Thiago Friedman
this way?
function handleSelect() {
 console.log(this);
 if (this.value == '30') {
 document.getElementById('agente_id').disabled = true;
 }
 }
– Michel Henriq
@Michelhenriq this, just to see if you are entering the function, if you are entering and give me the return
– Thiago Friedman
On the console nothing appears, and I let the other select disabled, and I select the option that has the value 30, and select does not quit the disabled..
– Michel Henriq
Let’s go continue this discussion in chat.
– Thiago Friedman