Laravel with laravel-admin panel

0

I'm new to Laravel and I'm using Laravel 5.3 with the Administration Panel called laravel-admin ( link )

I need to get the response from a radio button with Ajax before submitting the form.

The situation looks like this:

Use Medications? () Yes () No

If he ticks Yes, then I have to ask what medication he or she takes.

asked by anonymous 07.01.2017 / 21:10

1 answer

0

One solution would be for you to do this control with javascript:

document.querySelectorAll('[name="ReacaoAlergica"]').forEach(function() {
  this.addEventListener('click', function() {
    div_medicamentos.style.display = ReacaoAlergicaS.checked ? '' : 'none';
  });
});
Possui reação alérgica a algum medicamento?
<div>
  <input type="radio" id="ReacaoAlergicaS" name="ReacaoAlergica" value="1">
  <label for="ReacaoAlergicaS">Sim</label>

  <input type="radio" id="ReacaoAlergicaN" name="ReacaoAlergica" value="0">
  <label for="ReacaoAlergicaN">Não</label>
</div>

<div id="div_medicamentos" style="display: none">
  <label for="quais"> </label>
  <select name="medicamentos" >
    <option>Escolha o medicamento</option>
    <option>A</option>
    <option>B</option>
    <option>C</option>
  </select>
</div>

In the example I first look for elements that have the name equal to ReactionAlergic then I loop these elements to assign a click event, every time one of them is clicked I do a check to see if the yes option is I do not want to be able to do this in any way.

If you have jQuery, the example may decrease slightly:

$('[name="ReacaoAlergica"]').click(function() {
    div_medicamentos.style.display = ReacaoAlergicaS.checked ? '' : 'none';
});

NOTE: You should put all the ids and names as I put them in the example, so that the code works correctly.

    
08.01.2017 / 12:35