How to call JavaScript function from a PHP printed button -
what weird question. if has better title this, please go ahead , edit it; can't think of else call it. printing button php using echo
. purpose of button show form calling javascript function uses document.getelementbyid()
change style attribute of form tag visible form visible user. problem i'm having echoed string has have quotes around it, onclick
event has have quotes around it, , parameter passed javascript function has have quotes around it. tried escpaing quotes parameter backslashes didn't work. can me?
here code:
echo "<input type = 'button' onclick = 'showform(\'psswdform\')' value = 'change password'>";//this shows form , needs quotes
javascript function:
function showform(id) { document.getelementbyid(id).style.visibility = "visible"; }
this works fine me? (working example)
<?php echo "<input type = 'button' onclick = 'showform(\"psswdform\")' value = 'change password'>";//this shows form , needs quotes
generates:
<input type = 'button' onclick = 'showform("psswdform")' value = 'change password'>