Auto fill with a previous value

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

Auto fill with a previous value

Post by raphi5430 »

Hi!
I have the following question.
Is it possiblie that when you add a new row that you can auto fill a field with the value of the field from the previous row you added?


kirondedshem
User
Posts: 642

Post by kirondedshem »

1.create a function in global code to pick the latest value form whatever filed of whatever table. eg
GetLastestValue()
{
return ew_ExecuteScalar("SELECT field from table order by field_2 desc LIMIT 1");
}

  1. go to field settings of that field and in default Add->Default value paste the function as GetLastestValue(), not quotes, no termination

raphi5430
User
Posts: 8

Post by raphi5430 »

Thanks, that worked for me!


goldenaxe
User
Posts: 1

Post by goldenaxe »

kirondedshem wrote:
1.create a function in global code to pick the latest value form whatever filed of
whatever table. eg
GetLastestValue()
{
return ew_ExecuteScalar("SELECT field from table order by feild_2 desc LIMIT
1");
}

  1. go to field settings of that field and in default Add->Default value paste the
    function as GetLastestValue(), not quotes, no termination

Hello,
Thanks for your explain. I want to do the same thing. I'm a new user for phpmaker.
I can not do this . How can I create function in global code ? What is the mean of "global code "?

Thank you very much.


mobhar
User
Posts: 11660

Post by mobhar »

"Global Code" is a part of "Server Events" in your PHPMaker project. It is the place where your own code to be included in all PHP pages. This may contain your constants, variables, functions and classes.

For more info and example, please read "Server Events and Client Scripts" -> "Global -> All Pages" -> "Global Code" from PHPMaker Help menu.


Post Reply