Page 1 of 1

Navigator button javascript if statements not working as expected?

Posted: Wed Nov 27, 2013 8:51 pm
by Jason Baird

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....");
}


Navigator button javascript if statements not working as expected?

Posted: Wed Nov 27, 2013 9:01 pm
by Jason Baird

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....");
}


Navigator button javascript if statements not working as expected?

Posted: Wed Nov 27, 2013 9:01 pm
by Jason Baird

Close this ;)


Navigator button javascript if statements not working as expected?

Posted: Wed Nov 27, 2013 9:05 pm
by Maryna Brodina

:) Thank you for update