Reveal named div on radio select
See original GitHub issueIn some layouts it would be useful to reveal a div below the set of radio buttons based on the option selected.
The markup could work a bit like this:
{{ govukRadios ({
"id-prefix": "example",
"name": "example",
"fieldset": {
"legend": {
"text": "Example",
"isPageHeading": false,
"classes": 'govuk-fieldset__legend--m'
}
},
"items": [
{
"value": "1",
"text": "Option 1",
"conditional": {
"id": element_id
}
},
{
"value": "2",
"text": "Option 2",
"conditional": {
"id": element_id
}
}
]
}) }}
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Show div when radio button selected - javascript
so: If radio button #watch-me is checked --> div #show-me is visible. If radio button #watch-me is unchecked (neither are checked or the...
Read more >Show Hide DIV Based on Radio Buttons Selection Using ...
You can simply use the jQuery show() and hide() methods to show and hide the div elements based on the selection of radio...
Read more >How to Show and Hide div elements using radio buttons?
How to Show and Hide div elements using radio buttons? · Selector name for radio button is same as the element which is...
Read more ><input type="radio"> - HTML: HyperText Markup Language
A radio group is defined by giving each of radio buttons in the group the same name . Once a radio group is...
Read more >Show hide div on radio button
<p>How many check boxes do you want when clicked on a radio button?</p>. 2. <input type="radio" name="tab" value="igotnone" onclick="show1();" />.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Separating content from other content from which it is associated with in the markup needs particular consideration with regards to assistive technologies.
If we were going to introduce this as a proper feature, we’d need to be confident that it could be done in such a way that it didn’t introduce barriers for users of assistive technologies – especially screen readers and magnification tools.
We’d need to see evidence from user research with those users (of mixed abilities, i.e. not just ‘power’ users), showing that conditionally revealing another element elsewhere on the page (as in, not immediately following the radio button / checkbox) is clearly communicated to the user, that they understand that something has happened and how to navigate to the revealed controls.
We’d also need to see examples of cases where this pattern is shown to provide a better experience than e.g. splitting the form over multiple pages or using the existing conditional reveal pattern where the content is revealed immediately after the control.
We’ve found a workaround that isn’t too clunky:
Would be nice to find a more concise way of doing this bit:
{% if (data.createNewAccount.addRep == "no") or ( not data.createNewAccount.addRep) %}
Any ideas?