Manipulate the DOM to make multiple PUTs

0

In the image below, when clicking on 'change', I am able to change a field in the database, register the record, according to the number indicated by the user in the input next to the button.

Hereisthecode:

View:

<tbodyid="body">
                                    @foreach($imoveis as $imovel)
                                        <tr>
                                            {!! Form::open(['method' => 'PUT', 'route' => ['alterarPosicaoDestaque'], 'style'=>'display:inline', 'class' => 'delete']) !!}
                                                <input type="hidden" name="id" value="{{ $imovel->id }}">
                                                <td class="centro ordernar-id">{{ $imovel->id }}</td>
                                                <td>{{ $imovel->nome }}</td>
                                                <td class="centro">R$ {{ number_format($imovel->valor, 2, ',', '') }}</td>
                                                <td class="centro">@if($imovel->finalidade == 1) Imóvel à venda @else Imóvel para aluguel @endif</td>
                                                <td class="centro"><input type="text" value="{{ $imovel->posicaoDestaque }}" style="width: 100px" name="posicaoDestaque" class="form-control" placeholder="Posição"></td>
                                                <td>
                                                    {!! Form::button('Alterar', ['type' => 'submit', 'class' => 'btn btn-laranja']) !!} 
                                            {!! Form::close() !!}
                                            </td>
                                        </tr>
                                    @endforeach
                                    {{-- <button class="btn btn-laranja" id="btnAtualizar">Atualizar</button> --}}
                                </tbody>
                            </table>

The route file and the controller are not relevant now.

The problem is that this gets very tiring for the user, and I would like to create a single button, which would update all the records at once.

In other words, I'm not able to architect a way to go through the DOM and fetch the ID of each row from that table, link to the user's typed field and make a PUT for the required route.

How could I do this?

    
asked by anonymous 25.02.2018 / 06:26

0 answers