I have created a button which will call a JS function div_show()
echo '<div id="requestsample"><a name="1" onclick="return div_show(\''.$search_result['serviceid'].'\');" href="#1">';
This function will pass serviceid to JS.JS function will then call the PHP function add() to execute it.
<script>
function div_show($a) {
document.write($a);
document.write(' <?php add($a); ?> ');
}
</script>
<?php
function add($a)
{
echo $a;
//code for calculation
}
?>
PHP add function will exceute this statement only when I pass a specific numeric value.It is not dynamically taking the value of $a