I have the following code in php:
<?php
$apples = 123123;
echo "<td>
<input type='button' onclick='confirmation($apples)' value='ac/in'>
</td>";
echo('<script type="text/javascript">
function confirmation(test) {
var answer = confirm("Are you sure?")
if (answer){
alert(test);
$.get("/index.php?f=func_name_to_call",
{name: "John", hobby: "Programming"}, function(data) {});
}
}
</script>');
?>
If $apples is a number then the parameter gets passed correctly; however when it is a string, the function confirmation() is broken. Any ideas? Thanks in advance.
If you want it to pass argument as string use the below edited code
Just use
\for escaping the double quotes,and it will be considered as a string.