title: javascript function is not defined on button click
body: <p>i am dynamically creating a button element and on its onclick event seting a function call but its always saying removeimg is not defined (removeimg is name of function being called on click of button). hers the code :</p>
  
  <p>link :</p>
  
  <p><a href="http://shri-ram.lifekloud.com/pilot/step4.php" rel="nofollow">http://shri-ram.lifekloud.com/pilot/step4.php</a>
  (tab add delete photos)</p>
  
  <pre><code> function removeimg(){        
          //make request to remove the name
          document.getElementById(name).style.display = 'none';
          document.getElementById(btn12).style.display = 'none';
      }
  
  
  
      function showUploadedItem (source) {
          var list = document.getElementById("image-listalbum"),
              li   = document.createElement("li"),
              img  = document.createElement("img");
              var btn = document.createElement('input');
              btn.setAttribute("type", "button");
              btn.setAttribute("value", "Remove");
              btn.setAttribute("class", "t-button");
              var btnId = "btn" + source + "";
              btn.setAttribute("id", btnId);
              var func = "removeimg()";
              btn.setAttribute("onclick", func);
  
  
          img.src = 'uploads/'+source;
          li.appendChild(img);
          li.appendChild(btn);
          list.appendChild(li);
      }   
  </code></pre>