如何处理表单上自动建议多重输入的 $_POST 结果
我有以下 JsFiddle 来帮助解决我的问题:
我最终试图创建一个简单的输入字段,允许用户输入多个“名称”,从而向我们系统上的这些用户创建一条消息。在许多方面,这应该与在 Gmail 中撰写电子邮件完全相同(输入用户名/电子邮件的文本,自动建议出现,然后允许其他输入或提交)。
当我运行给定的代码时,$_POST 的结果非常奇怪。
根据选择的成员,键的值会发生变化:
array([as-results-0XXX]=>1,2,3,4)
,其中 XXX 不同,1,2,3,4 代表以下值选出的成员。这些值存储在单个元素中并用逗号分隔。最后,我想为每个选定的用户运行一个循环,并发送必要的警报:
如果选择了 3 个成员,例如,
foreach($rows as $row) {
do table insert with particular value
}
我的网站是使用 php 构建的,并且显然使用 jquery。我做了一些搜索,但找不到有关同一自动建议字段上的多个输入的任何内容。
I have the following JsFiddle to help with my question:
I am ultimately trying to create a simple input field which allows a user to enter multiple 'names' which creates a message to those users on our system. In many ways, this should function EXACTLY as Composing an email in Gmail (enter text for a user name/email, the autosuggests appears, then allow for additional input or submit).
When I run the code given, the results of the $_POST are quite strange.
Depending on which members are selected, the value of the key changes:
array([as-results-0XXX]=>1,2,3,4)
where XXX varies and 1,2,3,4 would represent the value of the members selected. These values are stored in a single element and separated by comma. In the end, I want to run through a loop for each user selected and send the necessary alert:
If 3 members are selected, e.g.
foreach($rows as $row) {
do table insert with particular value
}
My site is built with php and clearly using jquery. I have done a bit of searching and can find nothing regarding multiple inputs on the same autosuggest field.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过将
asHtmlID
属性添加到.autoSuggest()
来更改确定隐藏输入名称的方式:发布到您的 php 脚本的变量将通过以下方式可用:
$_POST['as_values_custom_id']
You can change the way the name of the hidden input is determined by adding the
asHtmlID
attribute to your.autoSuggest()
:The variable posted to your php script will be available through
$_POST['as_values_custom_id']