title: How to calculate values of a drop down menu with PHP/ JS?
body: <p>Hi I have been very puzzled how to do this and cannot find any relevant tutorial that could help me so I thought I would ask here and hope to find the help.</p>
  
  <p>I have a form with 2 drop down menus, each of them having a <code>value</code> attribute. What I want to do is allow someone to pick one item off one drop down and another off the other drop down.</p>
  
  <p>Once both drop downs have an item picked, the person is shown a total sum which is accumulated off the values from Drop Down 1 and Drop Down 2</p>
  
  <p>Here is my code which is nowhere near anything correct.</p>
  
  <pre><code>&lt;form&gt;
  echo "&lt;select name=Postage&gt;
    &lt;option value='14'&gt;1st Class&lt;/option&gt;
    &lt;option value='8'&gt;2nd Class&lt;/option&gt;
    &lt;option value='22'&gt;Next Day Delivery&lt;/option&gt;
    &lt;option value='0'&gt;Click And Collect&lt;/option&gt;
  &lt;/select&gt;
  &lt;br&gt;
  &lt;select name=Type&gt;";
  
  $type = "SELECT * FROM $category order by id";
  $item = mysql_query($type);
  while ($typeitem = mysql_fetch_assoc($item)) {
  
  echo "&lt;option value=$typeitem[price]&gt;$typeitem[type]&lt;/option&gt;";
  
  }
  
  $totalspend = Type.value + Postage.value;
  
  echo "
  Total £$totalspend
  &lt;/select&gt;
  &lt;/form&gt;";
  </code></pre>
  
  <p>I understand I will get replies saying you need to do this through javascript, but I have no idea how to implement this into a javascript code.</p>
  
  <p>Any help please?</p>