display one alert in javascript
Go to solution
Solved by Blade of Grass,
You need to created a state machine for this. Use one variable to track if it's fired and then check that before displaying the alert.
var hasFired = false; // procedure for the rest of the code // firing procedure if (!hasFired) { fireAlert(); hasFired = true; }
edit, sorry, didn't read your other message.
I would suggest you build a "Msg" variable that holds your entire alert message and fire it once.
var msg = ""; If (cond1) { Msg = Msg + "Something is wrong! "; } if (cond2) { Msg = msg + " Something else is wrong!"; } if (msg != "") { alert(msg); }
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now