Ok, I will update my instance to the version 5.4.3. I don't know if that version have the ajaxhelper package.
I only need that the box show me the results of my select depending on the letter I write.
I show you my tree files:
1. smart-search-widget.tcl
----------------------------
set js_update_user_select [ah::ajaxupdate \
-container "results_box" \
-url "search-users" \
-pars "Form.serialize('searchform')"]
2. smart_search_widget.adp
---------------------------
.
.
<.. id="searchform">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<.. type="text" name="search" id="search" onKeyUp="@js_update_user_select;noquote@ document.getElementById('results_box').style.visibility='visible';" autocomplete="off" value="" />
.
3. search_users.tcl
---------------------
ad_page_contract {
@author Ryan Gallimore (mailto:rgallimore@viscousmedia.com)
@creation-date 2006-09-23
} {
{search ""}
}
#ns_log notice "private-messaging search='$search'"
if { [string length $search] == 0 } {
ns_write "No results"
ad_script_abort
} elseif { [string length $search] < 3 } {
# Show all results if search string is 1 or two characters.
set search ""
}
set search [string tolower $search]
set package_id [ad_conn subsite_id]
set response ""
# Get users in the current subsite only
db_foreach get_search_results "
select n,n,n
from my_table
order by n
# select distinct u.username,
# p.first_names || ' ' || p.last_name as name,
# u.username as email
# from pers p, use u, acs_rels rel, app_groups ag
# where p.person_id = u.user_id
# and u.user_id = rel.object_id_two
# and rel.object_id_one = ag.group_id
# and ag.package_id = :package_id
# and (lower(p.first_names || ' ' || p.last_name) like '%$search%'
# or lower(u.username) like '%$search%')
# order by name
" {
set one_result "$name ($email)"
# Bold search text as you type
set start [string first $search [string tolower $one_result]]
set end [expr $start + [string length $search]]
set one_result_bolded "[string range $one_result 0 [expr $start-1]]<b>[string range $one_result [expr $start] $end][string range $one_result [expr $end+1] [expr [string length $one_result] - 1]]"
append response "<a href=\"#\">$one_result_bolded</a><br>"
} if_no_rows {
set response "No results"
}
ns_write $response
ad_script_abort