Jump to content


Photo

Cannot access radio buttons in form


  • Please log in to reply
1 reply to this topic

#1 mathieumg

mathieumg
  • Members
  • Pip
  • Newbie
  • 1 posts

Posted 18 February 2006 - 02:08 PM

Here is my HTML form:

<form method="post" action="page.php" id="regform">

<label><input type="radio" name="regracechoix[1]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[1]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[1]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[1]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[1]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[1]" value="hm" /> blablabla</label><br />

<label><input type="radio" name="regracechoix[2]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[2]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[2]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[2]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[2]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[2]" value="hm" /> blablabla</label><br />

<label><input type="radio" name="regracechoix[3]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[3]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[3]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[3]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[3]" value="hm" /> blablabla</label><br />
<label><input type="radio" name="regracechoix[3]" value="hm" /> blablabla</label><br />

<input type="button" onclick="verify()" />
</form>

and my verify function...

function verify()
{
        var BytIterateQuestion, BytIterateAnswers;
        var BytQuestionCount = 0;

        alert("Thix box does show up, but then nothing...");

        for( BytIterateQuestion = 1; BytIterateQuestion <= 10; BytIterateQuestion++ )
        {
            for( BytIterateAnswers = 0; BytIterateAnswers <= 5; BytIterateAnswers++ )
            {
                if( document.getElementById("regform").regracechoix[BytIterateQuestion][BytIterateAnswers].checked == true )
                {
                    BytQuestionCount++;
                }
            }
        }
        
        alert(BytQuestionCount);
}

I tried outputting the value of document.getElementById("regform").regracechoix[1][0] in an alert but nothing, so I am not able to access to my radio buttons :( If you have a idea why I would really appreciate your help!

Thanks a lot in advance!

#2 ccl

ccl
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 09 March 2006 - 12:17 AM

get rid of the brackets around the number at the end of the radio buttons on the form.
regracechoix1




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users