Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

99
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda