动态表单域 [英] Dynamic Form Fields

查看:115
本文介绍了动态表单域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不太清楚我要找的东西叫什么。如果我知道该怎么说,我可能会找到答案,所以如果你有一个答案我的问题,甚至知道我可以搜索,将是非常有用的。

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.

我正在尝试创建一个简单的php表单,其中包含名称,电子邮件等标准字段。我想添加一个事件类型字段,它是一个带有预先选择的值(即婚礼,生日等)的下拉列表。一旦他们选择一个特定的事件我想要其他选项出现。

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.

是否需要ajax或jquery或其他内容?

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?

感谢您的帮助。

推荐答案

你可以用jQuery来做到这一点。听起来你想要的不仅仅是动态的选择(下拉)输入。您可以查看此博文出来,但这只是涵盖了下拉字段。

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.

这听起来像是想要一些相当自定义的东西。您可以将表单分成单独的步骤,并隐藏许多字段以开始。使用jQuery,可以在事件选择时将事件处理程序应用于触发函数,然后该函数将决定要显示哪些字段。

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.

您不需要使用AJAX除非您需要选项(特别是下拉菜单)以包含从动态源(例如数据库)中提取的选项。

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).

这篇关于动态表单域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆