Page 1 of 1

[Added] nuGetValue(), nuSetValue()

Posted: Fri Apr 02, 2021 1:12 pm
by admin
The function nuGetValue() gets the value of a nuBuilder object.
The function nuSetValue() sets the value of a nuBuilder object.

If nuDebugMode is set to true in nuconfig.php, a warning is output in the developer console if the object (HTML element) does not exist.
This way you can see which objects do not exist or have been renamed and therefore can no longer be found.

E.g. to get the value of an Input Text Object:

Code: Select all

nuGetValue('my_text_input');
jQuery equivalent (which does not tell you whether "my_text_input" exists or not):

Code: Select all

$('my_text_input').val();

- To get the selected text of a Select object, pass a second parameter "text" nuGetValue('my_text_input', 'text');
- For a checkbox, the return value is true or false

E.g. to tick a Checkbox:

Code: Select all

nuSetValue('my_checkbox', true);
jQuery equivalent (which does not tell you whether "my_text_input" exists or not):

Code: Select all

$("#my_checkbox").prop('checked',true).change();