title: Shopping basket subtotal
body: <p>hoping someone can help me with this! got a simple order list but if someone clicks an option, but then changes their mind and clicks a different option, it just keeps adding the values together... not sure how to solve it... code is as follows</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
      total = 0;
      function Update_Subtotal(radio){
          price = radio.getAttribute("price");
          total = parseInt(total) + parseInt(price);
          document.getElementById("total").innerHTML = '£' + total;
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form name="form" method="post" action=""&gt;
      &lt;fieldset&gt;
          &lt;legend&gt;Option 1&lt;/legend&gt; 
          &lt;input type="radio" price="100" onclick="Update_Subtotal(this);" /&gt;Sub1
          &lt;input type="radio" price="200" onclick="Update_Subtotal(this);" /&gt;Sub2
          &lt;input type="radio" price="300" onclick="Update_Subtotal(this);" /&gt;Sub3
      &lt;/fieldset&gt;
      &lt;fieldset&gt;
          &lt;legend&gt;Option 2&lt;/legend&gt; 
          &lt;input type="radio" price="10" onclick="Update_Subtotal(this);" /&gt;Sub1
          &lt;input type="radio" price="20" onclick="Update_Subtotal(this);" /&gt;Sub2
          &lt;input type="radio" price="30" onclick="Update_Subtotal(this);" /&gt;Sub3
  &lt;/fieldset&gt;
  &lt;/form&gt;
  &lt;div id="total"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Now lets sell in Option 1 I select sub2 then in Option 2 I select sub 1... The total I get is 210 which is correct, but then, if I change my mind and in Option 2 I select sub 3, the answer I should have is 230, but the total I get is 240</p>
  
  <p>Thanks in advance for your help!</p>
  
  <p>James</p>