Patricia:

I updated this code so that it is using a variable to decide to update or add. I also added a large note to you to try to explain what WAS going on when this was done server side. You should be able to comment out a lot of the code. Please let me know if anything is not clear. I am not sure what you're going to send in here to determine if the user is trying to add or edit, but I will not be able to debug this even we can save it until it's done on your end because my code used loops that are gone now. Let me know if this is helpful and what else you need.
no changes