How to call javascript function on button click in php

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 echo. The purpose of a button is to show a form by calling a JavaScript function that uses document.getElementById[] 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 title 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?

Here is my code:

echo "";//this shows the form and needs quotes

JavaScript function:

function showform[id]
{
document.getElementById[id].style.visibility = "visible";
}

asked Apr 25, 2013 at 9:49

2

This works fine for me? [working example]

Chủ Đề