title: How to pass variable from PHP to JS, perform math on the variable then output to an on page element
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7705921/how-to-access-php-variables-from-within-javascript">how to access PHP variables from within JavaScript?</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to pass a variable from mySQL to PHP then to JavaScript to perform some math on it then have the result displayed on page in a specific area (in a <code>&lt;p&gt;</code> element with a specific ID assigned to it). Is this possible or is there an easier solution?</p>
  
  <p>Thanks!</p>
  
  <p>I already know how to get the variable from MySQL to PHP just having trouble on what to do after that.</p>
  
  <p>Here is my updated code after reading responses. Still not working but I am sure I'm doing something wrong!</p>
  
  <pre><code>&lt;p id="p_id"&gt;&lt;?php echo $price; ?&gt;&lt;/p&gt;
  &lt;input type="radio" group="radio_group" value="Reduce 10%" onclick="radio_click();" /&gt;
  
  &lt;script type="text/javascript"&gt;
  var price = &lt;?php echo $price; ?&gt;;
  
  function radio_click() {
  var target = document.GetElementById('p_id');
  var final_number; // this will be variable your store the final number in
  
  final_number = price * .9;
  target.innerHTML = final_number;
  
  }
  &lt;/script&gt;
  </code></pre>