Jason Baird
Posts: 0
Joined: Tue Nov 26, 2013 11:38 pm

Navigator button javascript if statements not working as expected?

Java script navigator button event click. I cannot seem to get this to work right and I'm hitting myself in the head, here is my test code and I'm banging myself in the head. This is just test code, but basically, I'm going to eventually pass the field value to a button and redirect to a page based on its value. In this code.. the alert it's a dog always comes up no matter what input is. Is there something I'm missing over here?

//input is a input field filled in with a service
//event is on click in navigator button
//input is equal to a string "dog"

var input = Appery('txtEquipment');

if (input = "") //it's blank
{
alert("blank");
}
else if (input = "dog")
{
alert("it's a dog"); //although input does not equal dog this always gets triggered whether "",="dog", or ="annything else"
}
else
{
alert("I have no idea what it is....");
}

Jason Baird
Posts: 0
Joined: Tue Nov 26, 2013 11:38 pm

Navigator button javascript if statements not working as expected?

see... right when I write a post I figure it out...

var input = Appery('txtEquipment');

if (input.val() == "") //it's blank
{
alert("blank");
}
else if (input.val() == "dog")
{
alert("it's a dog"); //although input does not equal dog this always gets triggered whether "",="dog", or ="annything else"
}
else
{
alert("I have no idea what it is....");
}

Return to “Issues”