Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

[Added] nuGetValue(), nuSetValue()

Information about updates, news, Code Library
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

[Added] nuGetValue(), nuSetValue()

Unread post 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();
Post Reply