title: Get number value from form, calculation, and updating html content with javascript
body: <p>I'm trying to make a very simple calculator in HTML and javascript
  But it still does not work</p>
  
  <p>My question are:<BR>
   1. How do I get value from a form and set it as a number, not a string? <br>
   2. How do I perform quadratic calculation in javascript?<BR>
   3. How do I update html content with javascript? So whenever I change the value of the input form and press submit, the result will change based on the input that I type, I've tried the <i>document.getElementById("idhere").innerHTML=valuehere;</i> but still does not work.</p>
  
  <pre><code>&lt;script tyle="text/javascript"&gt;
  function calculateThis(form) {
  var userweight=form.weight.value;
  var caffeineamount=form.caffein.value;
  var caffeinetimes=form.caffeintimes.value;
  var totalcaffeine=caffeineamount*caffeinetimes;
  
  // Calculate max caffeine per person
  var maxcaffeine=userweight*10;
  
  // Calculate remaining after 24 hours
  // Half life = 6 hours
  var totalcaffeineafter=totalcaffeine(1/16);
  
  // Calculating how many hours until the caffeine completely digested
  var totaldigest=totalcaffeine;
  var digesttime=0;
  
  while (totaldigest&gt;0.05) {
  totaldigest=totaldigest(1/2);
  digesttime++;
  }
  
  digesttime=digesttime*6;
  
  // Calculating when the user will probably die of overdose
  var countcaffeine=0;
  var overdosetime=1;
  
  while (countcaffeine&lt;maxcaffeine){
  countcaffeine=countcaffeine+totalcaffeine;
  overdosetime++;
  }
  
  // Show total amount of caffeine
  document.getElementById("showtotalkafein").innerHTML=totalcaffeine;
  
  // Show amount of caffeine after 1 day
  document.getElementById("showtotalkafeinsetelah").innerHTML=totalcaffeineafter;
  
  // Show digest time
  document.getElementById("showwaktudigest").innerHTML=digesttime;
  
  // Show overdose
  document.getElementById("showberapakali").innerHTML=overdosetime;
  
  return false;
  }
  &lt;/script&gt;
  
  &lt;form class="form"&gt;
  Weight&lt;br /&gt;  
  &lt;input type="text" name="weight" class="required" value="" /&gt;&lt;p /&gt; 
  Amount of caffein in coffee&lt;br /&gt;
  &lt;input type="text" name="caffein" class="required" value="" /&gt;&lt;p /&gt; 
  How many times drinking coffee in a day&lt;br /&gt; 
  &lt;input type="text" name="caffeintimes" class="required" value="" /&gt;&lt;p /&gt;
  
  &lt;button type="button" onclick="calculateThis(this.form); return false;"&gt;Calculate&lt;/button&gt;&lt;/form&gt;
  
  &lt;h1&gt;Result&lt;/h1&gt;
  &lt;p id="showtotalkafein"&gt;Show Caffein Total Here&lt;/p&gt; 
  &lt;p id="showtotalkafeinsetelah"&gt;Show Caffeine Amount After 24 hours&lt;/p&gt; 
  &lt;p id="showwaktudigest"&gt;Show Digest TIme Here&lt;/p&gt; 
  &lt;p id="showberapakali"&gt;Show Overdose Time Here&lt;/p&gt;
  </code></pre>