Page 1 of 2

Checkbox to set global HK

Posted: Wed Apr 26, 2023 6:59 pm
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

Re: Checkbox to set global HK

Posted: Wed Apr 26, 2023 7:02 pm
by kev1n
Please show your code.

Re: Checkbox to set global HK

Posted: Wed Apr 26, 2023 7:23 pm
by luca.ongaro
nuSetProperty('my_inq_tutti',checkbox_inq_tutti.value, true);

Re: Checkbox to set global HK

Posted: Wed Apr 26, 2023 7:44 pm
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')

Re: Checkbox to set global HK

Posted: Thu Apr 27, 2023 8:40 am
by luca.ongaro
It solved, thank you.

Re: Checkbox to set global HK

Posted: Thu Apr 27, 2023 8:52 am
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?

Re: Checkbox to set global HK

Posted: Thu Apr 27, 2023 8:57 am
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!

Re: Checkbox to set global HK

Posted: Thu Apr 27, 2023 9:03 am
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...

Re: Checkbox to set global HK

Posted: Thu Apr 27, 2023 9:51 am
by kev1n
nuGetValue() should always return true or false when used with a checkbox. Isn't that the case?

Re: Checkbox to set global HK

Posted: Thu Apr 27, 2023 11:34 am
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.