mardi 6 février 2018

Matching if statements to run code

I'm trying to match two values within two select boxes and run some JS if those values are selected & matched. I've tried the following code but can't seem to get it to work... Any ideas on what I'm doing wrong?

function airFunction() {
  if ([document.getElementById('destinations-list').value == "THAI"] && [document.getElementById('departure-from-list').value == "GLA"]) {

    alert("You picked Thailand & Glasgow!");

  } else {}

}
<select id="destinations-list">
  <option value="">Please select destination</option>
  <option value="THAI">Thailand</option>
  <option value="USA">USA</option>
</select>

<select id="departure-from-list">
  <option value="">Please select an airport</option>
  <option value="LGW">Gatwick</option>
  <option value="GLA">Glasgow</option>
  <option value="SEN">Southend</option>
</select>

Aucun commentaire:

Enregistrer un commentaire