title: Change php variable based on javascript value
body: <p>how can i change/assign a value to php variable depending on a javascript variable? 
  here is my code.</p>
  
  <pre><code>&lt;select id="reOutcome" name="reOutcome" onchange="OnChange(this.form.reOutcome);"&gt;
  &lt;option value="1"&gt;Value 1&lt;/option&gt;
  &lt;option value="2"&gt;Value 2&lt;/option&gt;
  &lt;option value="3"&gt;Value 3&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;script type="text/javascript"&gt;
  
  function OnChange(dropdown)
  {
      var myindex  = dropdown.selectedIndex
      var SelValue = dropdown.options[myindex].value
      if(SelValue==2){        
       &lt;?php
      $sCOMPFields .= "|"."SreComments";
      $sCOMPFields .= "|"."rePrID";   
       ?&gt;
      }
      return true;
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>The onchange function is working fine. I just don't know how to change the php variable. I searched online a lot. All im getting is how to assign php variable to javascript. That is not what im looking for.
  Thanks for your help.</p>