Invoke Auto fill

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
DEVELOPME
User
Posts: 14

Invoke Auto fill

Post by DEVELOPME »

In add page, I want to set a value of field to the value set through the link parameter and when set the value it should invoke the autofill to update the remaining fields depended on it.

For example,

My Lookup field name is : Emp_no , I have set up autofill for fields name, age, department

In add page, I am using a link parameter empno to set the filtered value when the add page gets loaded,

function Lookup_Selecting($fld, &$filter) {
if ( $this->PageID == "add" ) {
if ($fld->FldName == "Emp_no") {
ew_AddFilter($filter, "Emp_no = " . $_GET['empno]);
}
}
}

Selecting the lookup value in Row_rendered

function Row_Rendered() {
if ( $this->PageID == "add" ) {
$this->Emp_no->EditValue = $_GET['empno];
}
}

The problem is, the filed Emp_no is loading the value set through the parameter however the values of name, age, department are not getting auto filled properly.

How to fix this problem? Please help


danielc
User
Posts: 1601

Post by danielc »

Onchange event is not triggered by your server side code so there is no auto-fill. You may try to use javascript code (client side) to set your field value, Emp_no, (see api.jquery.com/val/) and to trigger the change event (see api.jquery.com/change/) instead of server event. See Server event and Client script in help file.


DEVELOPME
User
Posts: 14

Post by DEVELOPME »

Thank you for your suggestions, if you can paste a quick code it will very useful since I don't know much about java script programming.


danielc
User
Posts: 1601

Post by danielc »

Since you use $_GET, you can google "javascript code to get query string parameters" to find solution. Put your code in Client Scripts->Table-Specific->Add/Copy Page->Startup Script:

$(function() {
// get your query string value
$("#x<yourfield>").val(x); // replace <yourfield> with your actual field name
$("#x
<yourfield>").change();
});


Post Reply