hi
I'm trying to calculate string's integer value with the help java script,
i write java script in a function and i call it when ever i need to do that calculation, but it seems not working
first time ($a= cal(..)) is working but, the same function in second time ($b=cal(..)) by using previous values is not working.
KINDLY POINT OUT THE PROBLEM and help to solve it.
I'm trying to calculate string's integer value with the help java script,
i write java script in a function and i call it when ever i need to do that calculation, but it seems not working
Code:
<?php
function cal($x)
{
echo "<br>";
echo "x value =".$x;
$calculation= "<script type=\"text/javascript\">"."document.write(eval($x));"."</script>";
echo "<br>";
echo "calculated value".$calculation;
echo "<br>";
return $calculation;
}
$x="10";
$a= cal("$x+5");
echo "<br>";
echo "a value now".$a;
echo "<br>";
$b="$a+5";
echo "<br>";
echo "now b value=".$b;
echo "<br>";
$c= cal("$a+5");
?>
first time ($a= cal(..)) is working but, the same function in second time ($b=cal(..)) by using previous values is not working.
KINDLY POINT OUT THE PROBLEM and help to solve it.
Comment