Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Checkbox to set global HK

Questions related to customising nuBuilder Forte with JavaScript or PHP.
luca.ongaro
Posts: 64
Joined: Sun Jan 22, 2023 7:03 pm

Checkbox to set global HK

Unread post by luca.ongaro »

Hi,
I am trying to set a global hash cookie upon ticking an input/checkbox object on a browse form.
It works perfectly with input/text objects using onBlur event, but not with the input/checkbox.
I tried all events without success.
Where am I wrong?
Thanks
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Checkbox to set global HK

Unread post by kev1n »

Please show your code.
luca.ongaro
Posts: 64
Joined: Sun Jan 22, 2023 7:03 pm

Re: Checkbox to set global HK

Unread post by luca.ongaro »

nuSetProperty('my_inq_tutti',checkbox_inq_tutti.value, true);
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Checkbox to set global HK

Unread post by kev1n »

checkbox_inq_tutti.value always returns on

You could retrieve the checkbox value with

Code: Select all

nuGetValue('checkbox_inq_tutti').toString()
(returns 'true' or 'false')
luca.ongaro
Posts: 64
Joined: Sun Jan 22, 2023 7:03 pm

Re: Checkbox to set global HK

Unread post by luca.ongaro »

It solved, thank you.
luca.ongaro
Posts: 64
Joined: Sun Jan 22, 2023 7:03 pm

Re: Checkbox to set global HK

Unread post by luca.ongaro »

Is there a place in the nuBuilder documentation where I can find this kind of info? e.g. objects, properties, methods, etc?
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Checkbox to set global HK

Unread post by kev1n »

This has been reported as "bug" here.
https://github.com/smalos/nuBuilder4-Bu ... boolean.md

But this is probably not a bug, but rather a limitation of the function. The nuSetProperty function is designed to work with strings, so when you pass a boolean value directly to the function, it will not work as expected.

I'll make sure to add a note to the nuBuilder wiki documentation about this limitation of nuSetProperty and the need to convert boolean values to strings before passing them to the function. This will help other users who encounter the same issue in the future. Thank you for bringing it to our attention!
luca.ongaro
Posts: 64
Joined: Sun Jan 22, 2023 7:03 pm

Re: Checkbox to set global HK

Unread post by luca.ongaro »

Thank you.
To complete the picture, the toString() method applied to my checkbox sometimes returns "0" instead of "true". I managed with an OR, but it's weird...
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Checkbox to set global HK

Unread post by kev1n »

nuGetValue() should always return true or false when used with a checkbox. Isn't that the case?
luca.ongaro
Posts: 64
Joined: Sun Jan 22, 2023 7:03 pm

Re: Checkbox to set global HK

Unread post by luca.ongaro »

Hi kev1n, I made some tests with nuGetValue() and nuDebug(). I use checkboxes in nuuserhome to set global hashes and modify browse SQLs.
So, the issue is not with checkboxes, but with global HKs. They appear to be "1" or "0" in the first browse page, and "true" or "false" when I hit the bottom arrows to move to other pages.
Post Reply