title: Pass Parameters to JavaScript Function From Generated HTML
body: <p>I have an AJAX program which gets data from the website and posts the info to Facebook. My problem is quite simple. I need to generate HTML in the callback function. Here is a button:</p>
  
  <pre><code>var city = "Beijing";
  html+= "&lt;td&gt;&lt;input type=button value=FACEBOOK onclick=\"fb("+city+")\"&gt;&lt;/td&gt;";
  document.getElementById("myDiv").innerHTML = html;
  </code></pre>
  
  <p>Say I have the variable "city", and it has certain value. By generating the button like above, I cannot pass the city to the function fb(city). It even wouldn't invoke that function. However, it works if I remove the parameter.</p>