Dirty flag java script, dynamic drop down

Posted in :

stlplace
Reading Time: < 1 minute

Dirty flag on a HTML form is much trickier than I thought, that is, it is tricker when I started to programming for dirty flag.

Saw this javascript snippet. It works great except in my case, I was generating dynamic drop down (selection menu), and in a lot of cases it behaves as opposite to expected (i.e., it shows the form is dirty when it is not, and vice versa). Found out there are couple things came into play.

1) The default selection (type “0”), or select “nothing”, I forgot to set the value “0” (string type).

2) Second, I forgot to clear some of the derivative selections when I make selection the primary selection menu (basically it will dynamically generate other drop downs based on the primary selection).

3) Third, allow type “0” has other effect, I had to remove required=”true” validation from the selection menu, and validate it manually. Also, after I made this optional (removed required=”true”), the actionListener will get triggered when I make selection type “0”, previously it was not entering it, and caused other rendering issues.

4) Last but not least, I added a “validator” to the primary selection menu (basically it will give error if I select “0” type), and it will not trigger the actionListener again. Madness. So basically I have to do the validation somewhere else.

%d bloggers like this: