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, showfield 1
- if
b
is selected, showfield 2
- if
c
is selected,showboth fields
- if none of them is selected, hide both fields.
Table of Contents
Result
Prerequisites
Model your field as an options list with radio-buttons display option:
Code
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?
We can only get better if you give us constructive suggestions for improvement. Just voting "No" without giving reasons or suggestions is not helpful and cannot lead to changes.
If you have been searching for a completely different solution than the subject says, this article can not be and will not be helpful for you. In these cases you should consider not to vote.
This is website feedback, only. This voting is not a support form nor ticket system.