-2
greetings! I’m trying to do the following: in my select field has several values among them the other one that should only be used if the value is not in the field. and a text field coutro which by default is disabled and is only enabled if the user clicks another. I tried this way with Jquery but without success. I already know a lot of JS and Jquery. my Jquery script
<script>
$(document).ready(function(){
$('#tipo_contac').on('change',function(){
let tipo_contac = $(this).val();
if(tipo_contac === '{{$beneficiario->id}}')
{
$('#outro_cont').removeAttr('disabled');
}
else
{
$('#outro_contac').attr('disabled',true);
}
});
});
part of the form
<label>Nome do Contactante</label>
<div class="input-field col s4">
<select name="tipocontactante_id" id="tipo_contac" >
<option disabled="disabled" selected="selected default">Seleccione</option>
@foreach($tipo as $beneficiario)<!-- chama os dados dinamicamente do banco-->
<option value="{{$beneficiario->id}}">{{$beneficiario->tipo_contactante}}</option>
@endforeach
</select>
<label>Tipo Contactante</label>
</div>
<div class="input-field col s4">
<input type="text" name="empresa_contact">
<label>Empresa</label>
</div>
<div class="row">
<div class="input-field col s4">
<input type="text" name="contactante_outro" id= "outro_cont" disabled>
<label>Outro Contactante</label>
</div>
</div>
Dude, I strongly recommend you be like asking a question here in the OS. Another recommendation is you research more before asking a question. Your question is badly written and not very explanatory, help us to help you.
– M. Bertolazo
thanks for the recommendation
– egcelmi