Radio Button Values - Error with ".length"

I am trying to get the value from a series of radio buttons, and my method worked for the first set of 3, but when I repeated the procedure for the 2nd set of 3 radio buttons it didn’t work because of the “.length”

Working Code:


for (var x=0; x<Form.A111_answer.length; x++)
{
     if (Form.A111_answer[x].checked)
     {
          var A111_response=Form.A111_answer[x].value;
     }
}

Not-Working Code (immediately follows the previous code):


for (var x=0; x<Form.A122_answer.length; x++)
{
     if (Form.A122_answer[x].checked)
     {
          var A122_response=Form.A122_answer[x].value;
     }
}

This is the error I get:

Error: Number:-2146823281 Description:‘A122_answer.length’ is null or not an object

Any insight about the problem is much appreciated.

I figured out the problem and fixed it, but thanks anyway. :slight_smile:

Form.A122_answer must be somehow wrong. Can you provide the HTML that goes with this?

It also looks like there’s a lot of repetition and redundancy that could be remedied with some improvements to your code, which will make it easier to maintain and understand. Got to see the rest of the code though.