Ajax自动完成字段:显示一个值,但使用另一个值?

时间:2021-05-19 03:17:25

I've got an autocompleter in a CakePHP app that provides a dropdown list of neighborhoods to attach to a place. I'm pulling from a table 'neighborhoods' with name and id fields. I want the user to see the name of the neighborhood, and I want the app to see the id of the neighborhood and insert it into the places table. How can I make this happen?

我在CakePHP应用程序中有一个自动完成程序,它提供了一个附加到某个地方的社区下拉列表。我正在从名称和id字段的表'邻居'中拉出来。我希望用户看到邻域的名称,我希望应用程序看到邻居的ID并将其插入到places表中。我怎样才能做到这一点?

3 个解决方案

#1


1  

Another way of doing this would be to storing the id. Then when a user presses submit you replace the input field's value with your stored value.

另一种方法是存储id。然后,当用户按下提交时,将输入字段的值替换为存储的值。

#2


0  

assign the correct (hidden) value to a hidden input field

将正确(隐藏)值分配给隐藏的输入字段

#3


0  

This type of functionality is normally achieved with a combobox, which is like an autocomplete, with an underlying select elememt, see here

这种类型的功能通常使用组合框实现,它就像一个自动完成,具有底层选择元素,请参见此处

#1


1  

Another way of doing this would be to storing the id. Then when a user presses submit you replace the input field's value with your stored value.

另一种方法是存储id。然后,当用户按下提交时,将输入字段的值替换为存储的值。

#2


0  

assign the correct (hidden) value to a hidden input field

将正确(隐藏)值分配给隐藏的输入字段

#3


0  

This type of functionality is normally achieved with a combobox, which is like an autocomplete, with an underlying select elememt, see here

这种类型的功能通常使用组合框实现,它就像一个自动完成,具有底层选择元素,请参见此处