Home › Forums › JavaScript › Create a switch statement from an if (jQuery) › Re: Create a switch statement from an if (jQuery)
Yep, put this instead of this previous block:
if(response==’standard’)window.location.href=”/client-area/”;
if(response==’worldstores’)window.location.href=”/client-area/worldstores/”;
if(response==’wilko’)window.location.href=”/client-area/wilko/”;
else $(“#message”).html(“Sorry your username or password was entered incorrectly.”);
Talking about that, it should have been this:
if(response==’standard’)window.location.href=”/client-area/”;
else if(response==’worldstores’)window.location.href=”/client-area/worldstores/”;
else if(response==’wilko’)window.location.href=”/client-area/wilko/”;
else $(“#message”).html(“Sorry your username or password was entered incorrectly.”);
(with the else before every if) otherwise it would show the error if the response is not ‘wilko’ (even if it’s ‘standard’ for example).