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

185
Views
Update automaticaly switch button on checked

I have issues in my project. In deed, I want to update automatically a switch button when I check it. The case that I have is that when I click on the switch button, the page is refresh but the value is not changed.

my code :

<div class="col-4 text-left">
     <form  id="form" class="was-validated" method="POST" action="{{ route("admin.patients.update", [$patient->id]) }}" enctype="multipart/form-data">
     @method('PUT')
     @csrf
         <div style="float: right">
              <label class="switch">
                  <input type="checkbox" onchange="$('#form').submit();" name="cas_suivi" id="cas_suivi" type="checkbox" {{  ($patient->cas_suivi == "cas_suivi" ? ' checked' : '') }} >
                      <div class="slider"></div>
              </label>
          </div>
       </form>
     </div>

the controller:

public function update(UpdatePatientRequest $request, Patient $patient) { $patient->update($request->all()); return view( 'admin.patients.show', (compact('patient'))->with('success', 'Le patient a bien été modifié'); }
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

The result is:

    array:3 [▼
    "_method" => "PUT"
    "_token" => "Vo93U0F1uO1Ji7r03uVuENgq8JylZsEV5u6zQfRV"
    "cas_suivi" => "on"
    ]
over 4 years ago · Santiago Trujillo Report

0

After updating the table you need to redirect to the page again.

//change the route name if necessary

public function update(UpdatePatientRequest $request, Patient $patient) 
    { 
        $patient->update($request->all()); 
        return redirect()
        ->route('admin.patients.index')
        ->with('success', 'Le patient a bien été modifié'); 
    }
over 4 years ago · Santiago Trujillo 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!