Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

284
Vistas
How to execute form and after that onClick in Laravel

I want first to execute form and after that onClick(function) because the post form doesn't work.In this form if green button is submitted ,shows red button. After button is submitted I want to print hidden div. Thank you !

blade

 @foreach($movie->seats as $seat)
        <div id="printDiv" style="display:none;text-align:center">
            <h3 >Ред: 4</h3>
            <h3>Място: {{$seat->seat_id}}</h3>
            <h3>Филм: {{$movie->title}}<h3>
            <h3>Час: {{$movie->hour}}</h3>
            </div>
    @if($seat->reserved == 0)
    <form id="data" method="post" action="/seat/{{$seat->id}}">
        @csrf
        <button  type="submit"  onclick="printDiv('printDiv')" style="margin-left:10px; width:80px; display:inline;"  type="button" class="btn btn-success">{{$seat->seat_id}}</button>
        </form>
    @else
        <form  method="post" action="/destroy/{{$seat->id}}">
        @csrf
        
        <button type="submit"style="margin-left:10px; width:80px; display:inline;" type="button" class="btn btn-danger">{{$seat->seat_id}}</button>
        </form>
    @endif
    @endforeach

Script

function printDiv($idPage){
         
            var printContents = document.getElementById($idPage).innerHTML;
            var originalContents = document.body.innerHTML;
            document.body.innerHTML = printContents;

            window.print();
            document.body.innerHTML = originalContents;
        };

Controller

 public function changeReserved($id,Request $request){

        $request = Seats::find($id);
        $request->reserved = '1';
        $request->save();
     
        
        return redirect()->back();

        
    }
about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda