Masnad Nihit Masnad Nihit - 1 year ago 76
Javascript Question

sending a extra parameter in .submit

hello I have a function where I am using ajax to try to do get some value and then submit a php form which looks like this.

/* form-horizontal */
$attributes = array("class" => "form-horizontal", "id" => "register_form");

if (isset($_SESSION['login']))
if ($_SESSION['login'] == 'DoBusinessPerformed' || $_SESSION['login'] == 'NormalPerformed') {
echo form_open('myprofile/ManageProcessNew/'.$pathName, $attributes);
} else {
echo form_open('myprofile/RegisterProcessNew/'.$pathName, $attributes);
echo form_open('myprofile/RegisterProcessNew/'.$pathName, $attributes);

As you can see i have a .$pathname which is the parameter which contains the value 'borrow' and here is the ajax function which I am calling to send this form.

self.checkMangoPayId = function(){
type: 'POST',
url: BASEURL + 'index.php/myprofile/checkMangoPayID/' + auth,
contentType: 'application/json; charset=utf-8',
.done(function(data) {
if(data.mangopay_id == null){
alert("going to save page for mango id");
// here is where I submit the form

.fail(function(jqXHR, textStatus, errorThrown) {
alert("Error code thrown: " + errorThrown);


what I want to do is in the .submit function add a way to change the value of .$path name and put borrowed instead of borrow.

I tried a lot of ways like .submit(borrowed), but non of those ways work, so basically all I want to send a different value inside pathname to my controller which receives this parameter.

Answer Source

just before your submit you can add a attribute like this

$("#register_form").attr('action',BASEURL + "index.php/bla/bla/borrowed");

and then when you submit it will attach it at the back as parameter.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download