Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
PHP after browse in select object Topic is solved
-
- Posts: 315
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 87 times
- Been thanked: 11 times
PHP after browse in select object
Hello,
In certain situation, it is better to use a select object instead of lookup object because you don't want to have the select list modified by the end user.
In that case, using the select object is better.
In lookup object, it is quite easy to prepopulate the current form with php code. see below : Is it possible to do the same thing with a select field ? We probably have to create a procedure for that ? how can it be created ? Which event is used to call the php script ? Many thanks for your help,
Yves
In certain situation, it is better to use a select object instead of lookup object because you don't want to have the select list modified by the end user.
In that case, using the select object is better.
In lookup object, it is quite easy to prepopulate the current form with php code. see below : Is it possible to do the same thing with a select field ? We probably have to create a procedure for that ? how can it be created ? Which event is used to call the php script ? Many thanks for your help,
Yves
You do not have the required permissions to view the files attached to this post.
-
- Posts: 315
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 87 times
- Been thanked: 11 times
Re: PHP after browse in select object
Hello Kev1n,
Thanks for your answer.
I have created a proccedure I request like this below : and the procedure is : Unfortunately, it doesn't work. Do I made smthg wrong ?
Many thanks,
Yves
Thanks for your answer.
I have created a proccedure I request like this below : and the procedure is : Unfortunately, it doesn't work. Do I made smthg wrong ?
Many thanks,
Yves
You do not have the required permissions to view the files attached to this post.
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: PHP after browse in select object
nuSetFormValue() can only be used in After Browse. Use nuJavaScriptCallback()
https://wiki.nubuilder.cloud/index.php? ... ptCallback
and nuSetValue() to set a field's value.
https://wiki.nubuilder.cloud/index.php? ... ptCallback
and nuSetValue() to set a field's value.
-
- Posts: 315
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 87 times
- Been thanked: 11 times
Re: PHP after browse in select object
Kev1n,
Callback is something difficult to apprehend for me.
should be probably on custom code of det_type_id behind onchange() event.
But I don't see how to use nuJavaScriptCallback() and how to "send" $r to the javascript side.
Maybe like this ? Thx for your help,
Yves
Callback is something difficult to apprehend for me.
Code: Select all
nuSetValue('det_montant', $r->typ_montant)
But I don't see how to use nuJavaScriptCallback() and how to "send" $r to the javascript side.
Maybe like this ? Thx for your help,
Yves
You do not have the required permissions to view the files attached to this post.
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: PHP after browse in select object
Code: Select all
nuJavaScriptCallBack("nuSetValue('det_montant', $r->typ_montant);");
-
- Posts: 315
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 87 times
- Been thanked: 11 times
Re: PHP after browse in select object
Code: Select all
$s = "SELECT type.typ_montant FROM type where type.typ_code = ?";
$t = nuRunQuery($s, array('#DET_TYPE_ID#'));
if (db_num_rows($t) == 1) {
$r = db_fetch_object($t);
$js="nuMessage('test');";
//$js="nuSetValue('det_montant',$r->typ_montant);";
nuJavaScriptCallback($js);
}
it seems that my $t variable returns nothing. How can I see the content of my variable $t in php ? var_dump ?
det_type_id is a select object in the interface. Do I have to pass #DET_TYPE_ID# in the nuRunPHPHidden as a second parameter ?
Many thanks,
Yves
-
- Posts: 315
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 87 times
- Been thanked: 11 times
Re: PHP after browse in select object
Code: Select all
$s = "SELECT type.typ_montant FROM type where type.typ_code = ?";
$t = nuRunQuery($s, array('#DET_TYPE_ID#'));
$n = array('#DET_TYPE_ID#');
nuDebug($n);
if (db_num_rows($t) == 1) {
$r = db_fetch_object($t);
$js="nuMessage('test');";
//$js="nuSetValue('det_montant',$r->typ_montant);";
nuJavaScriptCallback($js);
}
Code: Select all
[0] : Array
(
[0] => #DET_TYPE_ID#
)
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: PHP after browse in select object
Is DET_TYPE_ID an object ID or is it set with nuSetPropety()?
It is case sensitive.
It is case sensitive.