0

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...

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Ezzaral
0

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.

0

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 :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.