How to call JavaScript function from a PHP printed button
<p>What a weird question. If anyone has a better title for this, please go ahead and edit it; I can't think of what else to call it. I am printing a button from PHP using <code>echo</code>. The purpose of a button is to show a form by calling a JavaScript function that uses <code>document.getElementById()</code> to change the style attribute of the form tag to visible so the form is visible to the user. The problem I'm having is that the echoed string has to have quotes around it, the <code>onclick</code> event has to have quotes around it, and the parameter passed to the JavaScript function has to have quotes around it. I tried escpaing the quotes for the parameter with backslashes but that didn't work. Can anyone help me?</p>

<p>Here is my code:</p>

<pre><code>echo "&lt;input type = 'button' onclick = 'showform(\'psswdform\')' value = 'Change password'&gt;";//this shows the form and needs quotes
</code></pre>

<p>JavaScript function:</p>

<pre><code>function showform(id)
{
document.getElementById(id).style.visibility = "visible";
}
</code></pre>
