I'm having a bit of trouble working with the quotations for this. So, let's make an example of sending two strings we want concatenated through variables, and then running them through a JavaScript function to concatenate them (I understand that this is very basic in PHP and I know how to do it, I'm just using this example for the sake of simplicity).
JavaScript Code:
function con(first, last) {
answer = first+last;
alert(answer);
return;
}
HTML and PHP:
<?php
$first = "Butter";
$last = "Last";
echo '<input type="button" value="Get Answer" onclick="con(".$first.", ".$last.")" />';
?>
This code above does not work, how can I make it work?
Thanks all
echo '<input type="button" value="Get Answer" onclick="con(".$first.", ".$last.")" />';intoecho "<input type='button' value='Get Answer' onclick='con(\"$first\", \"$last\");' />";