Welcome to the nuBuilder Forums!

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

Radio group

Questions related to using nuBuilder Forte.
Uzlander
Posts: 36
Joined: Sat Jul 08, 2023 10:21 am
Has thanked: 1 time
Been thanked: 2 times

Radio group

Unread post by Uzlander »

Hello everybody! Just fugured there's an input type Radio, but couldn't figure how to implement Radio Group to pick from.
So i only create separate buttons selectable (not even untickable), and there seem no configuration to assemble them as a group.
I basically want to assign it 'categories' (then serve as a filter for 'subcategories' dropdown).
Please help me understand
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Radio group

Unread post by kev1n »

Hi,

Good question!

If you want multiple radio objects to behave as a group (i.e. selecting one will unselect the others), you should give them the same name attribute.

For example:
radio_group_1.png
You do not have the required permissions to view the files attached to this post.
Guest

Re: Radio group

Unread post by Guest »

then i believe object's ID gonna be dynamic value for the Group ?
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Radio group

Unread post by kev1n »

Each object will still have its own ID. Do you want to retrieve the selected object/radio button of a group?
uzlander_ya
Posts: 5
Joined: Thu Apr 24, 2025 8:00 pm
Has thanked: 2 times

Re: Radio group

Unread post by uzlander_ya »

Would be good to see an example tracking the group's changing value due to selection of corresponding radio-button, and assign a group an onChange event to trigger other procedures down the work flow.
My scenario is following: Two base taxonomies(tables): Categories(Code, Description) and Subcategories(CategoryID, SubcategCode, SubcategDescription, etc..).
Then lets present Categories in the form as radio buttons(group) which upon selection/change trigger next element(dropdown) Subcategories to be filtered out accordingly. Its ok for me to have fixed set of categories-buttons. Now It seems LOOKUP field doesn't have a config to filter the table it looks up but SELECT field can utilize the flexibility of an sql so we use the Categories group's hashcookie there in the WHERE statement to have the dropdown (Subcategories)list filtered dynamically.
So here the radio group comed handy and looks as a neat implementation to me. Please show us how to track the current selected of a group
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Radio group

Unread post by kev1n »

For each readio button, add an onchange handler, e.g. handleRadioChange(this);
onchange.png

In the form's Custom Code field, add a function like this:

Code: Select all

// Called whenever a radio button's selection changes
function handleRadioChange(radio) {
  // Log the ID of the selected radio button for debugging
  console.log("Selected radio button ID:", radio.id);

  // Set a Hash Cookie, that is used in the select SQL, not quite sure what value should be set though
  nuSetProperty('your_hash_cookie', 'set_some_value_here');

  // Refresh a related select object to reflect any changes based on the new selection
  nuRefreshSelectObject('mySelectObjectId');
}
You do not have the required permissions to view the files attached to this post.
Uzlander
Posts: 36
Joined: Sat Jul 08, 2023 10:21 am
Has thanked: 1 time
Been thanked: 2 times

Re: Radio group

Unread post by Uzlander »

Good, and how about one checked by default? Cos 'defaultChecked/checked' added to attributes list didn't affect :(
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Radio group

Unread post by kev1n »

Add an onload event to the radio object you want to have checked when the form loads, then set its checked state using JavaScript: nuSetValue(this.id, true);
Uzlander
Posts: 36
Joined: Sat Jul 08, 2023 10:21 am
Has thanked: 1 time
Been thanked: 2 times

Re: Radio group

Unread post by Uzlander »

sorry, nuSetValue doesn't do default check, seems to me it just alters the id of an element
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Radio group

Unread post by kev1n »

In nucommon.js, function nuSetValue():

Modify

Code: Select all

	} else if (obj.is(':checkbox')) {
Replace with

Code: Select all

	} else if (obj.is(':checkbox') || obj.is(':radio')) {
Save changes, login again in nuBuilder and try again.
Post Reply