Sum duplicate items

By: Andres Garcia | Asked: 12/14/2022
ForumsCategory: General questionsSum duplicate items
Andres Garcia asked 1 year ago

I have a form with 2 fields. First field is Text, second is Numeric. Is there a way if someone enters  info into the text field, but an entry with that data already exists, to have the form sum the Numeric fields, thus maintaining 1 entry?

I would be fine if after it saw that a previous entry already exists, it copies the Numeric data from the older entry to this form and Sums the values....then deletes the older entry.


2 Answers
Victor Font answered 1 year ago
Store the value of the previous entry in a hidden field using this: Add the values in the current entry. Delete the previous entry after the new entry is saved. If you delete the previous entry before the new entry is saved, you won't have anything to refer to if the user decides not to submit the form.
Andres Garcia answered 1 year ago
What if it isn't the previous entry that I'm validating against, but any of the entries created?
Victor Font replied 1 year ago

Then you need to create custom code to gather the info you want to summarize and may need to use Ajax to determine the sum in real time.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community