Possible Duplicate:
php in javascript?
I need to check an if condition inside the inner html property of javascript. And so for that I need to use php inside it. So is it possible. I tried the following and it doesn’t seem to work.
document.getElementById().innerHTML =
"<?php if ($number == 1) { echo $ex; } else { echo $ey; } ?>";
So please help me out with this problem.
Your PHP is executed at the server. Once the page has been fetched, inserting PHP code into it at the client end via JavaScript, will not cause it to be executed.
You should store
$number,$ex,$eyin JavaScript variables and perform the same comparison in JavaScript.Firstly,
The above sets the values of JS variables.
Afterwards, you can call: