I'm creating dynamic buttons and forms for a website and would like the form hidden when it's corresponding button is clicked.
However, when I pass button and form name variables to my JavaScript that hides the form, the variables are not being recognised unless I explicitly set them. (e.g 1 and 2 as seen below).
In a nutshell the onlick event doesn't seem to like PHP variables !
Could anyone please explain why?
function showhide(button, form)
{
alert('form= ' + form);
alert('Button= ' + button)
$('button').click(function()
{
$('form').hide();
});
}
<?
// Setup Variables
$buttonName = "button" . $year . $period;
$formName = "form" . $year . $period;
?>
// Setup Dynamic Button
<input name="" type="button" id="<? echo $buttonName;?>" onclick="MM_callJS('showhide(1,2)')" value= "VAT" />
// Setup Dynamic form
<form action="" id="<? echo $formName; ?>" method="get" >