First of all, to break out of a loop you should use the "break;" command instead of changing the value of the iterator, but that's just a side note.
Are you getting any error messages in the JS console? Make sure to tick the option to show the console on error and warnings in the Preferences.
Without being able to see the form it is difficult to see what the problem is, can you upload the file to acrobat.com ( or some other sharing site)
There are zero error messages, it just acts like everything is perfectly fine and processes it but the value of i isn't correct so it's not working pass the 1st, nor is it processing the loop commands, however it will display 0 a few times. I didn't know about the break command.
I had a look at the file. It's an odd one... Actually, I think it's a bug in the way clearItems and setItems behave. They should both work on the field level (as opposed to the widget level), but it seems that they don't. If you remove the ".0" or ".1" etc. and try to use setItems, it fails.
My advice to you would be to rename your fields and not use periods, because that groups them together as multiple widgets of the same field.
Just call them ItemCode0, ItemCode1, etc., and then adjust your code accordingly. Then it should work just fine.
The code works fine for me. (Acrobat 9.4 Pro, WIndows XP)
It could be a version specific bug... I tested it on 8.1.3.