dimanche 8 octobre 2017

combining these two if statements ( javascript)

I'm doing my own project at home, when nothing to do just coding. Any idea how to combine these two if statements to work?, with javascript. The idea is, it should check if user wrote "1" and Latitude, Longitude are "63.10944", "21.59413", then it should let user in. Should i put two if's or two else if's ??

HTML:

<span class="form"><form>        
<input placeholder="Kirjoita Id" type="text" id="userInput"> 
<input type="button"
value="paina tasta"
onclick="unesi(); return false;">
</form> 
<p>Your text : <b id="ispis"></b></p>
</span>

JS:

var x = document.getElementById("demo");

function unesi() {
  var userInput, voteable;
  userInput = document.getElementById('userInput').value;
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition();

    if (userInput == "1" && Latitude: == "63.10944" && Longitude == "21.59413") {
      document.getElementById('demo').style.display = "block";
      document.getElementById('demo').style.filter = "initial";
      document.querySelector('.form').style.display = "none";
    }
  } else {
    document.getElementById('ispis').innerText = userInput;
  }
} 

Aucun commentaire:

Enregistrer un commentaire