Hi, I have a page with form on it. The form is linked to collection and able to add data to the database. Now, I want to do something with my data, before it actually gets submitted to the DB, send an Email for example. I know how to add a hook, but not sure how can I loop through all my items on the form to get their name and value. I don't want to hard code the names in my code, because there could be many input elements on the form and the form may change frequently.
Any ideas?
I think I get what you mean. I would create a backend module instead so you can pass an array to it with all the entered data. Then use wixData.update() to do whatever you want to the database in backend.
import { functionname } from 'backend/modulename'; export function submit_click(event) { let arr = []; for (let i = 0; i < enteredItems.length; i++) { arr.push([$w('#nameInput' + i).value, $w('#email' + i).value]); if (i === enteredItems.length - 1) { functionname(arr); } } }
Your question is not clear enough. Maybe you'd like to add a screenshot and to explain in details.