Ajax actions Ajax actions for form elements (added in v 4.3)

You can now directly perform ajax actions on form elements. For example, on change of textbox/dropdown, if you want to get the some data from database(or any other action) based on value of textbox/dropdown and put it in some textbox/dropdown, you can easily do this using the setAjaxAction function. By default, element on which you apply ajax, it's value will be passed directly. You need to define the function to be called using ajax in script/pdocrud.php and return the required output(if any). You can also define which other element values to be passed along with main element if required. Currently, it works with the textbox/dropdown only and there are some limitation on return value.

In the below example, we are calling the ajax function on change of the exam category id select box. We are also passing the value of student id just to explain how to pass other element's value. The ajax function getAmount is defined in the script/pdocrud.php. You can use the print_r to understand the content of the $data there.

Please note that this feature currently has some limitations as mentioned above and in future version, we will improve as per the requirement/feedbacks.

  
                                $pdocrud = new PDOCrud();
                                $pdocrud->relatedData('expense_category_id','expense_category','expense_category_id','name');
                                $pdocrud->fieldTypes("student_id", "select");
                                $pdocrud->fieldDataBinding("student_id", "student", "student_id", "first_name", "db");
                                /**
                                 * Set/Call ajax actions for the form elements on some js event
                                 * @param   string   $elementName                 Name of table column (element name) you want to apply event
                                 * @param   string   $event                       Javascript event name
                                 * @param   string   $callbackFunc                Function to be called upon
                                 * @param   string   $returnValueElement          On which element, return value should be displayed
                                 * @param   string   $otherElements               Other elements to be passed along if any
                                 * return   object                                Object of class
                                 */
                                $pdocrud->setAjaxActions("expense_category_id","change","getAmount","amount", array("student_id") );
                                 echo $pdocrud->dbTable("payment")->render("insertform"); // call render function
                                

Deprecated: Optional parameter $op declared before required parameter $task is implicitly treated as a required parameter in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOCrud.php on line 983

Deprecated: Creation of dynamic property PDOCrud::$langData is deprecated in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOCrud.php on line 2227

Deprecated: Optional parameter $page declared before required parameter $totalrecords is implicitly treated as a required parameter in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOCrudHelper.php on line 191

Deprecated: Optional parameter $parameters declared before required parameter $data is implicitly treated as a required parameter in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOCrudTableFormat.php on line 122

Deprecated: Creation of dynamic property PDOCrud::$ajaxActions is deprecated in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOCrud.php on line 2284

Deprecated: Creation of dynamic property PDOModel::$characterSet is deprecated in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOModel.php on line 119

Deprecated: Creation of dynamic property PDOModel::$characterSet is deprecated in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOModel.php on line 119

Deprecated: strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOModel.php on line 1011

Deprecated: strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOModel.php on line 1011

Deprecated: Creation of dynamic property PDOModel::$characterSet is deprecated in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOModel.php on line 119

Deprecated: strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOModel.php on line 1011

Deprecated: Creation of dynamic property PDOModel::$characterSet is deprecated in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOModel.php on line 119

Deprecated: strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOModel.php on line 1011

Deprecated: Creation of dynamic property PDOCrud::$dataHTML is deprecated in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOCrud.php on line 2379

Deprecated: Creation of dynamic property PDOCrud::$fieldList is deprecated in /home3/openscri/public_html/masinosinaga/pdo-crud/script/classes/PDOCrud.php on line 2380