+ 2
How to get the values of all radio button as array ?
function afterButtonClick() { var values = []; for( j = 1; j < 25; j++ ) { var ele = document.getElementsByName('radio'+j); for(i = 0; i < 2; i++) { if(ele[i].checked) { var result = ele[i].value; } values.push(result); } } alert(values); } Output values= yes,yes,No,yes,no like this
9 odpowiedzi
+ 3
You can use the for/of loop to iterate over the HTML collection of radio buttons. This way you don't need to worry about the length or index of the collection.
And within the loop push the element value, if it is checked, to the array.
https://code.sololearn.com/WoUrFl5expSO/#html
+ 1
Deep_Blue
Show only 1st value
+ 1
Want to get all button value after submit