-1

I want to check whether the value of x is zero or not...but the following code gives error... Warning: Use of undefined constant x - assumed 'x'

And the code is as follows:

<script>

        document.getElementById("select_user").onchange = function() {getAvailability()};
        function getAvailability() {
        var x = document.getElementById("select_user").value;
       alert(x);
        }                                                 
   </script>

       <?php if(x!==0) {?>
  • 3
    You probably should go and have a good, thorough read of [What is the difference between client-side and server-side programming?](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) first of all. – CBroe Jun 09 '20 at 09:03
  • 1
    you definitely can't get javascript variable in php this way – RainDev Jun 09 '20 at 09:05

1 Answers1

0

It depends on what you want to do, you can for example pass this variable by url params and in php check if they exist and acces them.

But specify what you wana do becouse maybe you can do this all in js

zywy
  • 100
  • 7