how to set a default selection in a dynamically generated radio buttons

1
0
-1

Hi,

I have a page made with UI designer which contains a radio buttons widget.

The available values are filled using a javascript expression retrieving all the groups the user belongs to :

function getGroupNames(data) {
var noms = [];
for( var i = 0; i < data.length; i++ ) {
noms[i] = data[i].group_id.name;
}
return noms;
}

return getGroupNames( $data.listeGroupes );

The selected value is a string variable.

When the page is displayed, no radio buttons is selected but I would like to select the first radio button by default.

I tried to set the value of the "selected value" variable at the end of the getGroupNames() function. It works but when I click on other radio button values, the black point in the button is not displayed anymore (although the values are correctly selected functionally)

Any hints?

Best,

1 answer

1
0
-1

Hello torea_1402565,

You need to put the default value in the formInput.

Exemple: {
"Decision":"Refused"
}

P.S: "Refused" is the value of the Radio Button

Comments

Submitted by torea_1402565 on Wed, 01/15/2020 - 20:40

Thank you for the hint but as the values are retrieved dynamically, how can i put the first value in the formInput as I don't know it at the beginning?

Notifications