title: javascript function not working in HTML
body: <p>I add oninput for every countable option so that the cost will be calculated and displayed on <code>order price &lt;h1&gt;</code> within <code>&lt;div&gt;</code>. I can't seem to display the message on my <code>&lt;h1 id="orderprice&gt;</code>. Why can't my javascript run and display the total cost on my html page?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function pizzacost() {
    var totalcost = 0
    if (document.getElementsByName("size").value = "small") {
      totalcost = totalcost + 22
    } else if (document.getElementsByName("size").value = "medium") {
      totalcost = totalcost + 28
    } else if (document.getElementsByName("size").value = "large") {
      totalcost = totalcost + 35
    }
  
  
    var options = document.getElementById('toppings').options,
      count = 0;
    for (var i = 0; i &lt; options.length; i++) {
      if (options[i].selected) count++;
  
      totalcost = totalcost + (count * 2)
    }
  
    if (document.getElementsByName("addon").value = "side of buffalo wings") {
      totalcost = totalcost + 5
    } else if (document.getElementsByName("addon").value = "garlic bread") {
      totalcost = totalcost + 3
    } else {
      total = totalcost + 8
    }
  
    totalcost = (totalcost * document.getElementsByName("quantity").value)
  
    document.getElementById("orderprice").innerHTML = "Total price for your order is $" + totalcost
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form&gt;
    &lt;h1&gt;Pizza Order Form&lt;/h1&gt;
    &lt;br /&gt;
    Type Of Pizza:
    &lt;select oninput="pizzacost()" required&gt;
      &lt;option value="please select..."&gt;Please select...&lt;/option&gt;
      &lt;option value="aloha chicken"&gt;Aloha Chicken&lt;/option&gt;
      &lt;option value="beef pepperoni"&gt;Beef Pepperoni&lt;/option&gt;
      &lt;option value="chicken delight"&gt;Chicken Delight&lt;/option&gt;
      &lt;option value="deluxe cheese"&gt;Deluxe Cheese&lt;/option&gt;
    &lt;/select&gt; Quantity:
    &lt;input oninput="pizzacost()" type="number" name="quantity" min="1" max="4" value="1" /&gt;
    &lt;br /&gt;
    Size:
    &lt;br /&gt;
    &lt;input oninput="pizzacost()" type="radio" name="size" value="small" required /&gt; Small
    &lt;input oninput="pizzacost()" type="radio" name="size" value="medium" required /&gt; Medium
    &lt;input oninput="pizzacost()" type="radio" name="size" value="large" required /&gt; Large
    &lt;br /&gt;
    Crust:
    &lt;br /&gt;
    &lt;input type="radio" name="crust" value="thin" required /&gt; Thin
    &lt;input type="radio" name="crust" value="thick" required /&gt; Thick
    &lt;input type="radio" name="crust" value="deep dish" required /&gt; Deep Dish
    &lt;br /&gt;
    Toppings:
    &lt;br /&gt;
    &lt;input oninput="pizzacost()" type="checkbox" name="toppings" value="mushrooms" /&gt; Mushrooms
    &lt;input oninput="pizzacost()" type="checkbox" name="toppings" value="sausage" /&gt; Sausage
    &lt;input oninput="pizzacost()" type="checkbox" name="toppings" value="olives" /&gt; Olives
    &lt;br /&gt; Addons:
    &lt;select oninput="pizzacost()" id="addon" multiple required&gt;
      &lt;option value="please select addons if required"&gt;Please select addons if required&lt;/option&gt;
      &lt;option value="side of buffalo wings"&gt;Side of buffalo wings&lt;/option&gt;
      &lt;option value="garlic bread"&gt;Garlic Bread&lt;/option&gt;
    &lt;/select&gt;
  
    &lt;div&gt;
      &lt;h1 id="orderprice"&gt;&lt;/h1&gt;
      &lt;script type="text/javascript" src="pizzaScript.js" defer&gt;&lt;/script&gt;
    &lt;/div&gt;
    &lt;br /&gt;
    Deliver to:
    &lt;br /&gt;
    &lt;input type="submit" name="submit" /&gt;
    &lt;input type="reset" name="reset" /&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>