What is the best way to code a dynamic form

Say I have a contact form with extra information.

I would need the user to click 1 of 3 options, and depending what option he clicks, then I would show 1 of 3 different (or additional, or less information) contact forms required depending on his choice.

All 3 form options would already be set, and there would not be any other information fields needed to be added.

Basically, I would just need information to show up, or not show in the form based on the user choice.

What would be the best way to make something appear and disappear onclick of a certain box choice?

Without knowing your particulars, we can make general suggestions at best. First question, have you gone though the javascript course?

I can see, for example, a <fieldset> with the class additional-options in your form and, based on the changing of a group of radio buttons, removing and replacing the contents of that fieldset.

You wouldn’t likely want to simply hide those optional form fields, as hidden form fields still get sent when the form submits.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.