dounuogong0358 2012-03-08 22:02
浏览 38

通过PHP调用javascript无法正常工作

I got a function that checks the value of a form and displays it to you before submission. Its written outside of PHP, but PHP is writing the HTML to call it when the user hits submit.

Well, I want to make it do more. I want it to display 2 values. I got it to do that, but I need it to pass the second value through PHP before displaying it. Basically the 2nd value is a number, and the number acts as an index key for an array with messages in it.

I figure it's as easy as passing more parameters to the function, but,

I need to know how to write that. I know you need to use double, not single quotes in order to parse variables in PHP, but the problem is the onClick already required double quotes, and breaking it into multiple echo statements doesn't seem to be working.

I swear, I change even one little thing about the javascript and for some reason it wont work at all.

I have no idea what's going on.

Here's a rough of the code.

Echo "<input type='submit' value='derrrrr' onClick='return confirmSubmit(this.form)' /></form>";

Where this.form is, I also need to pass $thearray[] (into the function).

  • 写回答

1条回答 默认 最新

  • dpjhq00684 2012-03-08 22:10
    关注

    Escape quotes in PHP by adding a slash before them.

    For example:

    <?php
    echo "<a href=\"#\" onclick=\"jsFunction();\">Click me</a>";
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么