views:

575

answers:

1

I have a form and have several text box, and a dropdown list. I am using the following jquery code to get the values of my form


// JQuery Code
    parentFormName = $(this).parents('form').attr('name');
    xajax_addNewRecord( xajax.getFormValues(parentFormName) );

My php code looks something like this:


protected function addNewRecord($formValues){

      $newRecordFirstName  = $formValues["newRecordName"];
      $newRecordLastName   = $formValues["newRecordLastName"];
      $newRecordSelection  = $formValues["dropDownSelection"]; // there is no info

       /**
        * some code goes here
        * ...
        */
      return $something;
    }

These code works really well, except the getFormValues does not have the information for the dropdown list in my form.

How can I get this value?

Thank you

NOTE: I'm using xDebug and the $formValues parameter does not even contains a "dropDownSelection" field in the array...

A: 

Ok, I have learned a few things about this method:

1) The method will not work if the form ID and the form name are not the same
2) All the elements of the forms must have a name and and id (they must match)
3) My problem was because I had two drop-down list with the same name :S

This method works really well as long as the form and all the elements in it have the right names and ids. Would be nice to have some documentation on some of these methods for xajax, but unfortunately there isn't, or if there is, there is no information just a reference to what the function does.

Onema