Dynamic Form Fields

[亡魂溺海] 提交于 2019-12-11 23:13:09

问题


I'm not exactly sure what to call the thing i am searching for. If I knew what to call it I might find the answer, so if you have an answer to my question or even know what I can search for that would be very helpful.

I am trying to create a simple php form that has standard fields like name, email, etc. I want to add an event type field that is a drop down with pre-selected values (i.e wedding, birthday, etc). Once they select a particular event I want other options to appear.

For exmaple they would select wedding and then date, venue, etc would then come up. If they selected birthday, then different additional options would appear.

Does anyone know the technical term for this, or where I can find a tutorial on it? Does it require ajax or jquery or something else?

Thanks for your help.


回答1:


You could do this with jQuery. It sounds like you want more than just dynamic select (drop down) inputs. You could check this blog post out, but that really only covers the drop down fields.

It sounds like you want something fairly custom. You could separate your form into the individual steps and hide many of the fields to start. With jQuery, you can apply event handlers to fire functions when something is selected and then the function would determine what fields to show.

You don't really need to use AJAX unless you need the options (specifically drop downs) to contain options which are pulled from a dynamic source (e.g. a database).



来源:https://stackoverflow.com/questions/4581453/dynamic-form-fields

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!