React to radio button selection

Another short article about using the (BETA) onChange handler for reacting to radio button selection changes with minimum code.

This is just for demonstration purposes.

There is an options list, not required, with options a, b and c.

  • If a is selected, show field 1
  • if b is selected, show field 2
  • if c is selected,show both fields
  • if none of them is selected, hide both fields.



Model your field as an options list with radio-buttons display option:


AppGiniHelper.DV.ready(function() { onReady(); });

function onReady() {
    new AppGiniField("test").onChange(function() { onTestChanged(); });    

function onTestChanged(value) {
    console.log("test changed: "  + value);
    new AppGiniField("injured_first_name").show(value=='a' || value=='c');
    new AppGiniField("injured_last_name").show(value=='b' || value=='c');

Do you like it?