Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!