SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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:
    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):
    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.

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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.

  3. #3
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

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


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •