douzhi1813 2013-07-25 06:25
浏览 6
已采纳

如何将PHP变量与JavaScript变量连接? 可能吗? [重复]

This question already has an answer here:

Java Script Code:

<script type="text/javascript">
        $(function () {
         var  seatNo = 2;                                                       
         str.push('<a title="' + seatNo + '">' + '<?php echo $thisPacket["seat"]; ?>'</a>');
         }); 
</script>

I want to concatenate between $thisPacket["seat"] with java Script variable seatNo.
Just like php concate. example: $i = 1; $thisPacket["seat".$i];

</div>
  • 写回答

5条回答 默认 最新

  • dragon012100 2013-07-25 06:35
    关注

    I want to concatenate between $thisPacket["seat"] with java Script variable seatNo. Just like php concate. example: $i = 1; $thisPacket["seat".$i];

    No, this won't work because the PHP code runs on the server, and the javascript variable seatNo is not available until the javascript code executes on the client.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 nrf52810-c三个a 程序
  • ¥15 lego-loam跑出来的roll误差很大
  • ¥50 求一个半透明没有锯齿的圆角窗体的实现例子
  • ¥15 STM32cubeMX里的FreeRTOS无法释放内存
  • ¥15 CATIA有些零件打开直接单机确定终止
  • ¥15 请问有会的吗,用MATLAB做
  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对