Enchufadoo
(Enchufado)
1
Hello, I’m trying to make a form like this
Select Dropdown
"Pick a type"
Doctor
Sector
If someone chooses Doctor I want this fields to appear:
Name
Surname
Address
If someone chooses sector I might use instead
Description
Floor
So my question is, can I do this on a single form, or maybe can I load a form according to the select?
Thanks in advance.
This is pretty basic JS.
You just create onchange handler for dropdown where show or hide other inputs (or even the whole forms).
The only tricky part here is validation, but it depends on how you store these forms.
Enchufadoo
(Enchufado)
3
Is there a way I can renderPartial on onchange?
Sure, just make an ajax request to an action that does renderpartial on ajax.
Dont forget to render required form if the select is already set to some value (update scenario)