I am trying to pass a value on the server side to the onclick handler of a tag, but it is giving different result on the client side when I click on the link.
My PHP code:
$any="link1";
echo(" <a id='link1' href='#' onclick='VisibleFalse($any)'>[+]</a><span><b>$candidatename</b></span>");
I want to pass the string "link1" to the function VisibleFalse, which is showing the string as an alert:
function VisibleFalse(ID)
{
alert(ID);
}
But it is printing "http://localhost/..." in the alert.
I would appreciate any of your suggestions.
Problem is, you’re passing a string and you forgot to add quotes to it so that the end result would be a string inside that JavaScript function. Here’s a better way to look at this: