title: Use of javascript variable in php if statement
body: <p>In my code i have done an ajax script with json and saved the variable you can see below. After that i'm trying to use the variable in my <strong>if statement</strong>, which is coded in php. Is it possible to do that? </p>
  
  <pre><code>          //Script variables 
                  var $trstatus_1; //value = GROUP_3, GROUP_2, GROUP_1 or UNDEF
             &lt;/script&gt;
  
             &lt;?php
  
                  //Status 
  
                  $id; //php variable
  
                  echo "&lt;div id='images'&gt;";
                  if($trstatus_1 == "GROUP_3"){
                      echo    "&lt;a id='".$id1."' class='tooltip1' href='#'&gt;&lt;img src='ball_red_glossy.png' alt='' width='70' height='50'  style='position: relative; left: 0px;' /&gt;&lt;span&gt;RED&lt;/span&gt;&lt;/a&gt;";
                  }   
                  else if($trstatus_1== "GROUP_2"){
                      echo    "&lt;a id='".$id1."' class='tooltip1' href='#'&gt;&lt;img src='ball_orange_glossy.png' alt='' width='70' height='50'  style='position: relative; left: 0px;' /&gt;&lt;span&gt;ORANGE&lt;/span&gt;&lt;/a&gt;";
                  }
                  else if($trstatus_1 == "GROUP_1"){
                      echo    "&lt;a id='".$id1."' class='tooltip1' href='#'&gt;&lt;img  src='ball_yellow_glossy.png' alt='' width='70' height='50'  style='position: relative; left: 0px;' /&gt;&lt;span&gt;YELLOW&lt;/span&gt;&lt;/a&gt;";
                  }
                  else if($trstatus_1 == "UNDEF"){
                      echo    "&lt;a id='".$id1."' class='tooltip1' href='#'&gt;&lt;img  src='ball_blue_glossy.png' alt='' width='70' height='50'  style='position: relative; left: 0px;' /&gt;&lt;span&gt;BLUE&lt;/span&gt;&lt;/a&gt;";
                  }
                  echo "&lt;/div&gt;";
             ?&gt;
  </code></pre>
  
  <p>So yes, the only question is if it is possible to use $trstatus_1 in my IF STATEMENT. and how :)</p>
  
  <p>BR</p>
  
  <p>Alex</p>
  
  <p>UPDATE</p>
  
  <pre><code>&lt;script&gt;
  
  setInterval("yourAjaxCall()",10000);
                  function yourAjaxCall() 
  
                  {
  
                      $.ajax(
                      {
                          type: "POST",   
                          url: 'api.php',                  //the script to call to get data          
                          data:  {vtrstatus: $V_TR_STATUS},                       //you can insert url argumnets here to pass to api.php
                          dataType: 'json',                //data format
                          success: function(data)          //on recieve of reply
                          {   
  
  
                              var trstatus = data[0].group_class;
                              trstatus_1 = trstatus;
                              var trstatus_1;
                              //alert(trstatus_1);
  
                          } 
  
                      });
                    };
   &lt;/script&gt;
  &lt;script&gt;
                  //Script variables
  
                  var trstatus_1;
                  var color;
  
                  if( $trstatus_1 == 'GROUP_1' ){
                      color = 'red';
                  }else if ( $trstatus_1 == 'GROUP_2' ){
                      color = 'orange';
                  }else if ( $trstatus_1 == 'GROUP_3' ){
                      color = 'yellow';
                  }else if ( $trstatus_1 == 'UNDEF' ){
                      color = 'blue';
                  }
  
                  var el = "&lt;a class='tooltip1' href='#'&gt;&lt;img src='ball_" + color + "_glossy.png' alt='' width='70' height='50'  style='position: relative; left: 0px;' /&gt;&lt;span&gt;" color.toUpperCase() "&lt;/span&gt;&lt;/a&gt;";
  
  
                  $('#images').append(el);
  
        &lt;/script&gt;
                  &lt;div id="images"&gt;
                  &lt;/div&gt;
  </code></pre>
  
  <p>Is this correct? </p>
  
  <p>BR  </p>