Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
54
rated 0 times [  57] [ 3]  / answers: 1 / hits: 7902  / 9 Years ago, sun, march 29, 2015, 12:00:00

I have the following form:



<form>
<input type=radio name=group-stack value=grouped checked>grouped<br>
<input type=radio name=group-stack value=stacked>stacked
</form>


I want to get the currently selected radio button's value using d3.



The following attempts have been unsuccessful:



var val = d3.select('input[name=group-stack]').checked; //undefined
var val = d3.select('input[name=group-stack][checked]')[0][0].value //always 'grouped' regardless of which radio is selected

More From » d3.js

 Answers
10

Try this



d3.select('input[name=group-stack]:checked').node().value

[#38285] Friday, March 27, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ellisw

Total Points: 625
Total Questions: 92
Total Answers: 88

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
ellisw questions
Mon, Aug 23, 21, 00:00, 3 Years ago
Fri, Nov 20, 20, 00:00, 4 Years ago
Sat, Jun 20, 20, 00:00, 4 Years ago
Tue, Apr 21, 20, 00:00, 4 Years ago
;