title: Using a variable for getElementById
body: <p>I have a checkbox that is being echoed by PHP. So, the id of the checkbox will be dynamic.</p>
  
  <p>So, I would like use a variable for <code>document.getElementById()</code>.</p>
  
  <p>Below is my PHP code:</p>
  
  <pre><code>echo "&lt;td&gt;&lt;input type='checkbox' name='edit$count' value='1' onclick='test($count)'&gt;&lt;/td&gt;";
  </code></pre>
  
  <p>Then here is my Javascript code</p>
  
  <pre><code>function test(v)
      {
          var edit = "edit" + v;
  
  
          if(document.getElementById(edit).checked==true){
              alert(edit);
          }
      }
  </code></pre>
  
  <p>However, when I clicked on the checkbox, there is no alert. </p>
  
  <p>Is there something wrong with my code?</p>