I have a group of radio buttons in a form, I need to pass the values of the selected radion buttons to a php script. So I need to build a json object to post.
I tried with this code, but I'm not sure. Please could anyone help me.
result = [];
for (i=0; i<document.getElementsByTagName('input').length; i++) {
if (document.getElementsByTagName('input').item(i).checked) {
s = document.getElementsByTagName('input').item(i).name;
r = document.getElementsByTagName('input').item(i).value;
result.push({id:s, va:r});
}