samedi 1 août 2015

Using if statements in for loops

Currently I am using an if statement inside of a for loop counting an array

for(count = 0; count < order.length; count++)
{
    if(order[count] == "")
    {
        alert("You must select an item");
        return false;
    }
    else
    {
        $.mobile.changePage();
    }
}

My issue is that if order[0] has information in it and if any other array index has no information the alert will still run when I don't want it to. Is there anyway to make sure that once the array is checked it just runs through the else statement without going back to the if statement.

Any help would be appreciated

John

Aucun commentaire:

Enregistrer un commentaire