views:

18

answers:

1

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

+2  A: 

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

Jonathan Kuhn
tried that. but still not workingthanks