title: cannot pass string to function
body: <p>I'm using javascript and I try to pass a string to a function , like so</p>
  
  <pre><code>        //example string
          var f="a";
  
  //add button that sends the value of f to the function
       document.getElementById("mydiv").innerHTML="&lt;input type='button' id='myButton' value='Click here' onclick='gothere("+f+");'&gt; ";
  
      function gothere(a){
      alert(a);
      }
  </code></pre>
  
  <p>I never see the alert and in console I see <code>a is not defined</code> (refers to the f I guess?)</p>
  
  <p>If i set the f <code>var</code> to be a number then I see the alert.</p>
  
  <p>What am I missing?</p>
  
  <p>Thanks in advance</p>
  
  <p>EDIT</p>
  
  <p>I was thinking maybe something like</p>
  
  <pre><code>var buttonnode= document.createElement('input');
  
  document.getElementById("mydiv").appendChild(buttonnode);
  buttonnode.onclick=gothere(f);
  </code></pre>
  
  <p>Wont work for the same reason?</p>