1

I am currently discovering JavaScript and I have some problems... I want to to set a check box to checked by using Js, but it doesn't seem to work. :/

Here is the HTML code:

<td><input id="jm" type="checkbox" onClick="check(1)"></td>
<td><input id="conference" type="checkbox" name="casmaret"></td>

Here is the Js code:

 function check(valeur)

     switch (valeur)
     {
         case 1:
                  document.getElementById("jm").checked = true;
                  document.getElementById("conference").checked = true;
                  break;
      }
 }

I simplified it, but the fact is, I want to check some other checkbox by checking one checkbox. When I look over the debugger in Chrome, the function executes, but it doesn't change anything...

Any ideas?

Thanks

David Aleu
  • 3,922
  • 3
  • 27
  • 48
Zarwag
  • 33
  • 1
  • 1
  • 4

1 Answers1

3

You are missing a { after your function check(valeur):

function check(valeur)
{
     switch (valeur)
     {
         case 1:
                  document.getElementById("jm").checked = true;
                  document.getElementById("conference").checked = true;
                  break;
     }
}
Devator
  • 3,686
  • 4
  • 33
  • 52