开发者

javascript and PHP problem

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜