Page 1 of 1

Trap onclick event from Textbox

Posted: Fri Feb 24, 2023 4:34 pm
by rmassard
Hi there,
I am just about to discover nubuilder and are stuck now because I want to run a procedure by clicking on a field in a browse form. I'm using custom code of the textbox in object view. There is no action, however simple, when clicking on the field.
Can the onclick event be used on a textbox ? Or only buttons ? Or what other type of objects ?
If there is a way, how can I pass a parameter to the PHP procedure (nuRunPhpHiddenWithParameters)
Txs for your help

Re: Trap onclick event from Textbox

Posted: Fri Feb 24, 2023 4:59 pm
by kev1n
nuSelectBrowse() runs when any record on a Browse Form is selected.

And here's a simple example how to use nuRunPHPHiddenWithParams().

In JavaScript:
The function runProc() calls the nuRunPHPHiddenWithParams() function with three arguments:

- 'myproc': a string indicating the name of the PHP procedure to be executed.
- 'myparams': a string representing the a Hash Cookie to be passed to the PHP procedure.
{activity: '111', task: '222'}: an object that contains additional parameters to be passed to the PHP procedure.

Code: Select all

function runProc() {
    nuRunPHPHiddenWithParams('myproc', 'myparams', {
        activity: '111',
        task: 'something'
    });
}
Add a Procedure:
proc.png

Code: Select all

$myparams = nuGetProperty('myparams'); // Retrieve the Hash Cookie

if ($myparams) {

    $myparams = json_decode(base64_decode($myparams)); // Decode it

    $activity = $myparams->activity;  // Retrieve the parameters
    $task = $myparams->task;

    // Output du nuDebug Results
    nuDebug($activity, $task);

}

Re: Trap onclick event from Textbox

Posted: Fri Mar 03, 2023 9:48 am
by kev1n
Hi,

Could you please let me know if my answer helped and if you were able to get it to work? I would greatly appreciate any feedback you can provide. Thank you!