If checkbox is checked do

Hello,
I’m a kind of novice in webDev. May I ask you help to do something please ?

I have multiple checkbox. I have to retrieve the value of the checkbox who will be checked. Sure I can not know which checkbox the user will check. Then my script has to retrieve which is checked.

Code exemple:

        <input id="a"  type="checkbox" value="a" onclick="getChecked()" />
        <input id="b"  type="checkbox" value="b" onclick="getChecked()" />
        <input id="c"  type="checkbox" value="c" onclick="getChecked()" />

I could tell you what I tried but I think what I’m asking is not so hard then maybe you could just tell me the solution if you could help me.

Thank you very much !

I have found the answer.

here is the javascript code I needed to implement:

            var input = document.getElementsByTagName('input');

            for(var i=0; i<input.length; i++)
            {    

                if(input[i].checked) alert('input[i].value');
            }

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.