I looked through many similar examples, but I could not make this work.
So, I have this:
echo('<td colspan="3" style="background-color:#005673; text-align:right; padding: 4px 0px;">
<button class="btnTrack" onClick="trackIt(' . $name . ')" >Track It!</button></td>');
That code is inside a for, so the variable $name will be different depending where I am at.
I am not trying to make things complicates, so first, I am just trying to pass that parameter to the function trackIt (I actually need to pass 2 of them.)
Then, I have a simple script (just to see if it will work):
<script>
//After you click on Track It
function trackIt(param)
{
alert("Hi!");
alert(param);
}
</script>
However, it does not work.
If my onClick
function is just onClick="trackIt()"
, then it works fine and I can alert "Hi!" by removing the parameter.
Thanks for the help! =]