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

228
Views
Jquery to change form action and, Pass user id through action

I have a modal where a user fill the data and when user press the submit button, a id fetch from jQuery and save data in datable according to the user id. So, I have to fetch the id from jQuery and have to pass through PHP variable.

Here is my query for changing my form URL:

$('#get_form').attr('action', '{{ url("admin/report/update/"."$id="obj.data('id'))" }}');

And, here is my form

<form action="" id = "get_form" method="post" class="ajax-form modal-content" enctype="multipart/form-data">

I am unable to set the URL perfectly.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You're mixing blade with js. Try formatting the url like this:

const url = "{{ url('admin/report/update/:id') }}".replace(':id', obj.data('id'))
// generates admin/report/update/1 assuming obj.data('id') is equal to 1

$('#get_form').attr('action', url);
over 4 years ago · Santiago Trujillo Report

0

 var id = $('some-id').val();  // a hidden value

 var url = "{{ url('admin/report/update/') }}" + id;

 $('#get_form').attr('action', url);
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!