Depending of certain form values, I update via JavaScript the action attribute to redirect to a different success page (for example /congratulations), however it always takes me to the default /thanks page.
Yup, it is. We record the action at DEPLOY time, and you cannot change it. Perhaps your result page could have conditional behavior instead of trying to have a conditional page address?
Do you mean pointing your action attr directly to the function URL or setting up a submission webhook to point to the function in the Netlify Forms webhook settings? I’m doing the latter in my current form.
Similar to the OP, I’m trying to use dynamic input names in my form, and I’m starting to realize this isn’t possible through Netlify Forms, because the names are not predefined in Netlify at deploy.
So maybe the solution is to bypass Netlify Forms and hit my function directly, and process my form data there? I suppose I’d just lose some of Netlify’s features (honeypot, GUI submission administration, etc.).