I AM WEAK IN JAVASCRIPTING, PLEASE HELP ME.THIS IS MY BASIC IDEA TO TOGGLE VALUES USING JAVASCRIPT

<?php $xyz=5; ?>
<head>
<script type="text/javascript">
var x;
function displaymessage()
{

if (x==5)
 {
 alert("yes");
 x=1;
 }
else
 {
 alert("no");
 x=5;
 }
}
</script>
</head>
<body>
<form>
<input type="button" value="Click me!" onclick="displaymessage();" />
</form>

<p>By pressing the button above, a message WILL APPEAR.</p>

</body>

NOW I WANT TO USE THE SAME LOGIC SO THAT I CAN TOGGLE PHP VARIABLE ON CLICKING THE BUTTON.ON CLICKING FIRST TIME, THE PHP VARIABLE SHOULD RETURN 0, ON CLICKING SECOND TIME, IT SHOULD BE VALUE OF $xyz. and so on...

1. No need for caps and bold I can read just fine.
2. Java !== Javascript. It never has been nor never will.
3. Try posting this in : http://www.daniweb.com/forums/forum117.html not here.
As a quick hint you cannot directly access a server variable from Javascript (a client side language). You will need to either form post back to the server or you will need to make an ajax request to the server.

That about covers it.

For future reference, you can click the "Flag Bad Post" button and request the post be moved to the correct forum :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.