dongliqin6939 2010-07-15 19:10
浏览 11
已采纳

Javascript和php值切换

I have index.php page and I have this there

$pv->showHidden = isset($_POST['showHidden']) ? intval($_POST['showHidden']) : 0;
$pv->sendHidden = isset($_POST['showHidden']) ? 0 : 1;

and then I have this

<input type="image" id="btnShowHidden" src="images/hide.gif" onclick="showHiddenRecords(<?php print $pv->sendHidden; ?>);" />

I have javascript that has this function

  function showHiddenRecords(x){
 alert(x);
 var n = new Object();
 var showHidden;
 if(x=1){Y=0;} else {Y=1;}
 n.showHidden = Y;
 Ajax.Post("index.php", n, pg.test(x));

}

What I am trying to do is to toggel the value of $pv->showHidden . So if it is 1 (already selected) then it will become 0 and vice versa. But logic isnt working.
Thanks in advance

  • 写回答

1条回答 默认 最新

  • dongzz4545 2010-07-15 19:13
    关注

    you have if(x=1) in your function. should be if(x==1) to compare. or else you are just setting x to 1.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度