0

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 toggle the value of $pv->showHidden, so if it is 1 (already selected) then it will become 0 and vice versa, but the logic isn't working.
Thanks in advance

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.