1
I’m developing a system to evaluate a user (typical of stars), but I’m having problems passing values to PHP.
Javascript code:
function mouseClick(id){
var valorVoto = document.getElementById(id).value
valorVoto = valorVoto.split("#")
voto = valorVoto[4]
<?php $voto = "<script>document.write(voto)</script>"; ?>
}
PHP code:
if(isset($voto)){
echo 'Passou';
}
When I open the page it does not wait for the click of the button, it simply gives echo.
As the very name of PHP (Hypertext Preprocessor) states, it is a preprocessed language and so can not do what you want. PHP just processes the code and shows the result, so you can only use it in a new request, for example ajax
– Valdeir Psr
In my star rating system I use ajax, as @Valdeirpsr suggested
– Wees Smith
Thanks for the suggestion of Ajax, but I managed to do only with PHP and JS.
– Leandro