开发者

javascript and PHP problem

开发者 https://www.devze.com 2023-02-06 15:19 出处:网络
i have a problem when trying to include php with javascript i have an: if(document.getElementById(acheckbox).checked==true){

i have a problem when trying to include php with javascript

i have an:

if(document.getElementById(acheckbox).checked==true){
<?php $result=$result."开发者_运维知识库bar-";?>
}
else{
<?php $result=$result."none";?>
}

but both are executed... so $result is>>>bar-none how can i solve this problem??? please help!


That JavaScript code, while it's in a source file on your server, is just plain text to output.

It's not code that's executed by the PHP interpreter.

Both pieces of PHP code will always run.


your else statement needs to be written in php not in javascript.


You must be put echo.

<?php echo $result."food" ?>

other wise you should write like this

<?=$?>
0

精彩评论

暂无评论...
验证码 换一张
取 消