is there a limet to how many if else stamets you can have? cause i am having a proble were the javascript will run or skip the 1st part of the if but then when it hits the else it eneds the program. the 1st part will work no mater what is in there but it hits the else statment and stops
I don't know if a specific hard limit exists, but I was able to create an "insane" test case which had 3,600 else if statements for a button mouse-up event. I say insane because using an extreme number of "else if" statements is considered very poor coding style. If you are using a large number of "else if" statements you might want to consider using a "case" statement instead.
Your description of unexpected "if else" execution seems to point to misplaced or missing curly braces "{" and "}".
With all the snow in Chicago, my snow globe crystal ball is not working. Without seeing the code and knowing which product you are creating your form in, it is not possible to diagnose the problem. You could try simpliying your code to one else statement and get that code to work and then add the next else statemt. Also open the JavaScirpt debugging console and see if there are any errors being reported. And as previously noted the "switch", "case", control statement might be a better solution.
The simplist form:
switch (myFieldValue) {
case "John" : // code for John break; // end John exit
case "Jack": // code for Jack break: // end Jack exit
case "Joe": case "Joseph": // code for Joe and Joseph break; // end Joe and Joseph default: // all other options not selected break; // end all others } // end of switch
By replacing the value in the "switcht(value)" with a logical value of "true" the labels for the "case" can be complex statments that can evalute to 'true" or "false" allowing for very complex comparisons.
George Kaiser