duan39779 2016-07-24 03:00
浏览 42

如何在php中嵌入的javascript中连接变量?

I'm using the following code but it is not concatenating the "show" and X although X is defined as var X=1.

echo"  <li class=\"\" id=\"frame\"
onClick=\"ballFunctions[\"show\"+X]();\"><a href=\"#\"> <b> $value</b>
</a> </li> <script type=\"text/javascript\"> X++; </script>  ";

Is there any syntax problem?

  • 写回答

2条回答 默认 最新

  • douben1891 2016-07-24 04:11
    关注

    I don't know if your code is correct, but here is the code:

    echo '  <li class="" id="frame"
    onClick="ballFunctions[\'show\'+X]();"><a href="#"> <b> '.$value.'</b>
    </a> </li> <script type="text/javascript"> X++; </script>  ";
    

    Here X seems to be a JS variable...

    评论

报告相同问题?