-3

I'm going to use if in blade Laravel that when they select married show more input.

And also take int for children for example when type 4 show more 4 input.

It is a form that client put their information and if they have wife another input shows to get their name and if they have children show more input.

I couldn't write the codes please help me

<div class=" form-group col-md-4">
    <label for="" class="text-form"> وضعیت تاهل  </label>
    <select class="form-select" name="material" aria-label="Default select example">
        <option value="single">single</option>
        <option value="married">married</option>
    </select>
</div>

<div class="form-group col-md-4">
    <label class="text-form">  number of children  </label>
    <input type="text" class="form-control" placeholder="childeren  ">
</div>
cokeman19
  • 2,405
  • 1
  • 25
  • 40

2 Answers2

1

Check “If statements” at laravel.com docs

Example

@if (count($records) === 1)
    I have one record!
@elseif (count($records) > 1)
    I have multiple records!
@else
    I don't have any records!
@endif
Georgii
  • 77
  • 5
0

I would use javascript (jQuery) for this job:

Something like the following code:

$(document).ready(function() {
  $("#hidden_input").hide();
  $("select.legal_state").change(function(){
    if ($(this).children("option:selected").val() == 'married') {
      $("#hidden_input").show();
    } else {
       $("#hidden_input").hide();
    }
  });
});
<div class=" form-group col-md-4">
    <label for="" class="text-form"> وضعیت تاهل  </label>
    <select class="form-select legal_state" name="material">
        <option value="single">single</option>
        <option value="married">married</option>
    </select>
    <input type="text" id="hidden_input"/>
</div>

<div class="form-group col-md-4">
    <label class="text-form">  number of children  </label>
    <input type="text" class="form-control" placeholder="childeren  ">
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

Edit: I made it disappear again when you select single