如何将搜索功能添加到AJAX驱动的自动建议搜索字段(How to add search functionality to an AJAX

编程入门 行业动态 更新时间:2024-10-28 08:17:43
如何将搜索功能添加到AJAX驱动的自动建议搜索字段(How to add search functionality to an AJAX-driven auto-suggest search field)

我正在使用他的代码调用一个CFC,它通过AJAX返回自动提示结果。

<cfinput type="text" class="titleSearchField" name="TitleName" autosuggest="cfc:gz.cfcomp.search.AutoSuggestSearch({cfautosuggestvalue})">

现在做什么只是生成一个自动建议列表。 点击其中一个自动生成的结果不会执行任何操作,但会将其保留在输入字段中。 点击时如何让搜索表单访问结果页面? 是否必须使用onClick属性并将结果传递给另一个查询以完整处理结果?

在下面的建议中,我添加了以下内容:

action="search.cfm?GameID=#AutoSuggestSearch.GameID#"

但它引发了一个错误,即GameID未在AutoSuggestSearch中定义(尽管我从CFC查询中选择它)。

I'm using he following code the call a CFC which returns auto-suggest results through AJAX.

<cfinput type="text" class="titleSearchField" name="TitleName" autosuggest="cfc:gz.cfcomp.search.AutoSuggestSearch({cfautosuggestvalue})">

What this does right now is only generate an Auto-suggest list. Clicking on one of the auto-generated results does nothing, but retain it in the input field. How do I make the search form visit a results page when clicked? Do I have to use the onClick attribute and pass the results for an additional query to full process the result?

At suggestion below I added the following:

action="search.cfm?GameID=#AutoSuggestSearch.GameID#"

But it's throwing an error that GameID is not defined in AutoSuggestSearch (although I am selecting it from in the CFC query).

最满意答案

你有没有尝试在cfinput上使用onChange? 通过这种方式,当您选择该值时,您可以发出表单帖子(或另一个ajax请求)来执行搜索。

Did you try using onChange on the cfinput? That way when you select the value, you can fire off a form post (or another ajax request) to do a search.

更多推荐

results,search,CFC,电脑培训,计算机培训,IT培训"/> <meta name="descriptio

本文发布于:2023-07-07 09:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1061393.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段   如何将   搜索功能   建议   search

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!