Using Clone () in laravel

0

I'm trying to make a copy of both format and content (one input and 2 select), so that at the moment of pressing a button, that mini form appears, to put it some way below the original, I have researched and they tell me that with the .clone of java it can be done, but I do not know how to occupy someone can you guide me or help me?

HTML CODE

<div id="divInsumos">
   <div id="formularioInsumo">
      <div class="col-lg-3 col-md-12 col-xs-12">
          <label for="nameP" class="col-form-label text-md-right">{{ __('Insumo') }}</label>
       <div class="form-group">
           <select class="form-control input-lg select2 select2-hidden-accessible" tabindex="-1" aria-hidden="true">
           @foreach ($insumo as $Insumos)
              <option value="{{ $Insumos['id'] }}"> {{    $Insumos['nombreI'] }}</option>
           @endforeach
           </select>
        </div>
     </div>
   <div class="col-lg-2 col-md-6 col-xs-12">
        <label for="nameP" class="col-form-label text-md-right">{{ __('Unidad de medida') }}</label>
            <div class="form-group">
            <select class="form-control input-lg select2 select2-hidden-accessible" tabindex="-1" aria-hidden="true">
               <option selected="selected">Seleccionar</option>
               <option>Kilogramo/s</option>
               <option>Litro/s</option>
               <option>Metro/s</option>
               <option>Unidad/es</option>
            </select>
            </div>
          </div>
    <div class="col-lg-2 col-md-6 col-xs-12">
        <label for="nameP" class="col-form-label text-md-right">{{ __('Cantidad') }}</label>
        <input type="number" min="1" class="form-control input-lg" placeholder="1">
</div>
</div>
</div>

BUTTON TO ADD

<div class="col-md-1 col-xs-4 .col-xs-offset-4">
  <button type="button" class="btn btn-block btn-primary" id="btnMas">MAS</button>
</div>
    
asked by Matias Muñoz 26.10.2018 в 21:05
source

1 answer

0

You should add the jquery library and then on the button you could do something like this:

<div class="col-md-1 col-xs-4 .col-xs-offset-4">
    <button type="button" class="btn btn-block btn-primary" id="btnMas"
        onclick="$('#formularioInsumo').clone().appendTo('#divInsumos')">MAS</button>
</div>

What we do there is find the form div, clone it and add it to the first div.

I hope it serves you.

Good luck!

    
answered by 29.10.2018 в 00:49