dougan4663 2014-08-05 09:40 采纳率: 0%
浏览 47

在Firefox上禁用JavaScript意味着我的按钮不起作用,是否有办法编写按钮以便它们可以工作?

So I have written a basic page which has buttons:

<button type="button" onclick="minus()"> </button>

with the script:

function minus() {
  if (<?php echo $number ?> > 1){
  var num = <?php echo $number; ?> - 1;
  var number=num;
  window.location.href = "page2.php?w1=" + number;}
};

So this just subtracts 1 off of a PHP variable and it works perfectly well in Chrome, IE and Safari, but in Firefox it doesn't work at all. Is this a security thing is this code particularly insecure?.

Is there any way in which I can write a button to change this PHP variable without using JavaScript as to make it work on Chrome, IE, Safari + Firefox?

Many thanks

  • 写回答

2条回答 默认 最新

  • dongtan1845 2014-08-05 12:14
    关注

    PHP is a server-side language - JavaScript a client-side language; PHP is executed before Javascript, so by the time your Javascript function is initiated the PHP code is already gone.

    Take a look at this: Using PHP in javascript's IF Statement.

    It might help!

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog