title: Auto update the value of a .php variable based on radio button selection without submitting or refreshing
body: <p>I'm Trying to update the <code>$total_charge</code> variable with the value of the "shipping radio button" without having to refresh or submit the page. I believe this can be done using JavaScript, but I'm not sure how. The code I'm using is below. </p>
  
  <p>Any suggestions?</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  
  &lt;?php
  $qty = $_POST["qty"];
  $style = $_POST["style"];
  $price = $_POST["price"];
  
  $lense = $_POST["lense"];
  $lense_chunks = explode("|", $lense);
  $tax = .08*(($price+$lense_chunks[1])*$qty);
  $total_charge = ($tax + $shipping) + (($price+$lense_chunks[1])*$qty);
  
  ?&gt;
  
  
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;p&gt;&lt;strong&gt;Price&lt;/strong&gt; = &lt;?php echo $price;?&gt; &lt;br /&gt;
    &lt;strong&gt;QTY&lt;/strong&gt; = &lt;?php echo $qty;?&gt;
    &lt;br /&gt;
    &lt;strong&gt;Style&lt;/strong&gt; = &lt;?php echo $style;?&gt;
    &lt;br /&gt;
    &lt;strong&gt;Lense&lt;/strong&gt; = &lt;?php echo $lense_chunks[0];?&gt;
    &lt;br /&gt;
    &lt;strong&gt;Lense Fee&lt;/strong&gt; = &lt;?php echo $lense_chunks[1];?&gt;
    &lt;br /&gt;
    &lt;strong&gt;Tax&lt;/strong&gt; = &lt;?php echo $tax;?&gt;&lt;br /&gt;
    &lt;strong&gt;Shipping&lt;/strong&gt; = Standard ($5.00)
  &lt;label&gt;
      &lt;input name="shipping" type="radio" id="RadioGroup1_0" value="5.00" checked="checked" /&gt;
  &lt;/label&gt;
    Overnight ($20.00)
    &lt;input type="radio" name="shipping" value="20.00" id="RadioGroup1_0" /&gt;
    &lt;br /&gt;
    &lt;strong&gt;Total Charge&lt;/strong&gt; = &lt;?php echo $total_charge;?&gt;
  &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>