Jump to content

Cannot access radio buttons in form


mathieumg

Recommended Posts

Here is my HTML form:

[code]
<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>
[/code]

and my verify function...

[code]
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);
}
[/code]

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!
Link to comment
Share on other sites

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.