title: Javascript if statement based on dropdown menu value
body: <p>I have a question about the if statement in js. I made a statement, but it doesn't seems to work. I want to check these statements from one single click on "button 1". The script is to check if there are any transportation costs before I calculate the total.
  Can someone tell me how to fix my problem?</p>
  
  <p>Here's my script:
      </p>
  
  <pre><code>&lt;SCRIPT TYPE="text/javascript"&gt;
  function berekeningen()
  {
  
  if (document.getElementById("DropdownMenu1").value = "Eeklo" &amp;&amp; document.getElementById("Order_Subtotal").firstChild.data &gt;= 20)
    {
    document.getElementById("Transportation_Cost").value="0.00";
    }
  else
    {
    document.getElementById("Transportation_Cost").value="3.00";
    }
  
  if  (document.getElementById("DropdownMenu1").value = "Adegem" &amp;&amp; document.getElementById("Order_Subtotal").firstChild.data &gt;= 25)
    {
    document.getElementById("Transportation_Cost").value="0.00";
    }
  else
    {
    document.getElementById("Transportation_Cost").value="3.00";
    }
  
  if  (document.getElementById("DropdownMenu1").value = "Kaprijke" &amp;&amp; document.getElementById("Order_Subtotal").firstChild.data &gt;= 25)
    {
    document.getElementById("Transportation_Cost").value="0.00";
    }
  else
    {
    document.getElementById("Transportation_Cost").value="3.00";
    }
  
  if  (document.getElementById("DropdownMenu1").value = "Lembeke" &amp;&amp; document.getElementById("Order_Subtotal").firstChild.data &gt;= 25)
    {
    document.getElementById("Transportation_Cost").value="0.00";
    }
  else
    {
    document.getElementById("Transportation_Cost").value="3.00";
    }
  
  if  (document.getElementById("DropdownMenu1").value = "Oosteeklo" &amp;&amp; document.getElementById("Order_Subtotal").firstChild.data &gt;= 25)
    {
    document.getElementById("Transportation_Cost").value="0.00";
    }
  else
    {
    document.getElementById("Transportation_Cost").value="3.00";
    }
  
  if  (document.getElementById("DropdownMenu1").value = "Sint-Laureins" &amp;&amp; document.getElementById("Order_Subtotal").firstChild.data &gt;= 25)
    {
    document.getElementById("Transportation_Cost").value="0.00";
    }
  else
    {
    document.getElementById("Transportation_Cost").value="3.00";
    }
  
  if  (document.getElementById("DropdownMenu1").value = "Ursel" &amp;&amp; document.getElementById("Order_Subtotal").firstChild.data &gt;= 25)
    {
    document.getElementById("Transportation_Cost").value="0.00";
    }
  else
    {
    document.getElementById("Transportation_Cost").value="3.00";
    }
  
  if  (document.getElementById("DropdownMenu1").value = "Waarschoot" &amp;&amp; document.getElementById("Order_Subtotal").firstChild.data &gt;= 25)
    {
    document.getElementById("Transportation_Cost").value="0.00";
    }
  else
    {
    document.getElementById("Transportation_Cost").value="3.00";
    }
  
  if  (document.getElementById("DropdownMenu1").value = "Zomergem" &amp;&amp; document.getElementById("Order_Subtotal").firstChild.data &gt;= 25)
    {
    document.getElementById("Transportation_Cost").value="0.00";
    }
  else
    {
    document.getElementById("Transportation_Cost").value="3.00";
    }
  
  if  (document.getElementById("DropdownMenu1").value = "Knesselare")
    {
    document.getElementById("Transportation_Cost").value="5.00";
    }
  
  if  (document.getElementById("DropdownMenu1").value = "Lovendegem")
    {
    document.getElementById("Transportation_Cost").value="5.00";
    }
  
  if  (document.getElementById("DropdownMenu1").value = "Bassevelde")
    {
    document.getElementById("Transportation_Cost").value="5.00";
    }
  
  if  (document.getElementById("DropdownMenu1").value = "Maldegem")
    {
    document.getElementById("Transportation_Cost").value="5.00";
    }
  }
  &lt;/SCRIPT&gt;
  </code></pre>
  
  <p>Edit:
  I changed the script a bit with variables but it doesn't work</p>
  
  <pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.js"&gt;&lt;/script&gt;
  
  &lt;SCRIPT TYPE="text/javascript"&gt;
  function berekeningen()
  {
     var plaats           = document.getElementById("plaats").value;
     var kosten           = document.getElementById("kosten").value;
     var subtotaal        = document.getElementById("Bestelling_subtotaal").firstChild.data
     var class_1_plaatsen = new Array("Eeklo");
     var class_2_plaatsen = new Array("Adegem", "Kaprijke", "Lembeke", "Oosteeklo",
                                      "Sint-Laureins", "Ursel", "Waarschoot", "Zomergem");
     var class_3_plaatsen = new Array("Knesselare", "Lovendegem", "Bassevelde", "Maldegem");
  
     if ($.inArray(plaats, class_1_plaatsen) &gt;= 0) {
  
        // Berekening voor plaatsen in prijscategorie 1 hieronder.
  
     }
     else if ($.inArray(plaats, class_2_plaatsen) &gt;= 0) {
  
        // Berekening voor plaatsen in prijscategorie 2 hieronder.
  
     }
     else {
  
        // Berekening voor overige plaatsen hieronder.
  
     }
  }
  &lt;/SCRIPT&gt;
  </code></pre>
  
  <p>I wan't to make this:</p>
  
  <blockquote>
    <p>When var plaats = class_1_plaatsen and subtotaal &lt; 15, then alert (We
    leveren vanaf minimum € 15).  But if subtotaal is between 15 and 20,
    then kosten = 3. But if subtotaal >= 20, then kosten = 0. </p>
    
    <p>When var plaats = class_2_plaatsen and subtotaal &lt; 20, then alert (We
    leveren vanaf minimum € 20).  But if subtotaal is between 20 and 25,
    then kosten = 3. But if subtotaal >= 25, then kosten = 0. </p>
    
    <p>When var plaats = class_3_plaatsen and subtotaal &lt; 20, then alert (We
    leveren vanaf minimum € 20).  But if subtotaal >= 20, then kosten = 5.</p>
  </blockquote>
  
  <p>Dyasten</p>