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

100
Vistas
How to submit form when sidebar clicked

I have a sidebar with a form inside each menu. I want to submit a form whenever user click a menu inside the sidebar with different data from foreach. The sidebar menu also created inside foreach.

<li class="nav-item has-sub sidebar-group-active">
             <a href="javascript:void(0)"><span class="menu-title">Choose Company</span></a>
                <ul class="menu-content" style="">
                    @foreach ($company as $cp)
                        @if ($cp->name != Session::get('selected_company'))

                         //Whenever user clicked this list item
                          <li class=""><a href="javascript:void(0)" id="company"><span class="menu-item"
                                data-i18n="eCommerce">{{ $cp->name }}</span></a>
                         </li>

                         // I want to submit this form
                         <form action="{{ route('select_company') }}" method="POST">
                            @csrf
                            <input type="hidden" value="{{ $cp->name }}" name="selected_company">
                         </form>
                        @endif
                    @endforeach
                </ul>
            </li>

How to do it using JQuery? I've tried to search how to solve it and found this way:

   <script>
        $('#company').click(function() {
            $(this).closest('form').submit();
        });
    </script>

But it still not working, when I click the sidebar menu nothing was happened. Any help would be very helpful for me, thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If I was you I would do something like this;

   <li class="">
     <form action="{{ route('select_company') }}" method="POST">
     @csrf
       <input type="hidden" value="{{ $cp->name }}" name="selected_company">
       <input type="submit" value="{{ $cp->name }}"/>
    </form>
</li>

and then style your submit button as you like

about 4 years ago · Juan Pablo Isaza Denunciar
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