|
You could put the Cityname and PostalCode in the value, using a separator as semicolon or another. "Cityname1;PostalCode1", "Cityname2;PostalCode2", "Cityname3;PostalCode3", &c.
You will have to split the value later with javascript.
Regards
|
|
|
|
|
I have over 200 items in the list.
Typing gra gets these results -
Aa Gradient
Ascites Albumin Gradient
Kilogram <==> Pound
Transtubular Potassium Gradient
However, if I now clear the search box (clicking backspace repeatedly) and type single character a
The results are -
Aa Gradient
Ascites Albumin Gradient
Kilogram <==> Pound
Transtubular Potassium Gradient
ABG
Acute Lung Injury Ratio
Age from DOB
Allergy-Immunology
Alveolar Gas Equation
As you can see the results from the earlier search are appearing first.
Can you please help?
Sanjay Khandkar
|
|
|
|
|
Hi Sanjay,
I'll look over this issue today, thank you for reporting.
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
ChooserMethod:
when 1, choose all that start with what's entered. h -> honda, hyundai
when 2, choose all that enclosed (strstr in C) what's entered. h -> honda, hyundai, lamborghini
when 3, like 1 if only 1 character entered, like 2 if more that one are entered.
Item 3 could be configurable for character count that triggers behavior.
|
|
|
|
|
I think it is already implemented:
this.limit_start = false; // should the auto complete be limited to the beginning of keyword?
If NOT what you needed, let us know.
If this IS what you need, next time please RTM!
Bye
|
|
|
|
|
<asp:textbox id="employees_m" runat="server" visible="true" cssclass="INPUTBOX" autopostback="true">
new autosuggest("employees_m", employees_m);
If I input "Alain" and then I select "Alain Trepanier" from the list I only get "Alain" in employees_m.Text in this code behind function:
Private Sub employees_m_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles employees_m.TextChanged
End Sub
How to get the value ?
BTW great article! We will donate.
PS: If you can, I'd like more details for the cases using AJAX i.e. your solution two. Now I inject javascript variable from Code behind.
|
|
|
|
|
Hi,
I'm not quite proficient in ASP.NET, but autopostback seems a bad practice here.
What I can say: maybe you should create an additional autopostback input field (id="employees_addon") write:
new autosuggest("employees_m", employees_m, "", function(index, control)
{
document.getElementById("employees_addon").value = control.values[index];
});
?
AlainTrepanier wrote: PS: If you can, I'd like more details for the cases using AJAX i.e. your solution two. Now I inject javascript variable from Code behind.
You'll need a simple webservice, that accepts a textstring (start of keyword entered), and outputs a text string (see article). Any problems here?
Hope it helps,
Dmitriy.
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
Here is my solution:
'In the page:
<asp:textbox id="employeeTxb_m" runat="server" visible="true" cssclass="INPUTBOX" autopostback="false">
new autosuggest("employeeTxb_m", employees_m, "", function(index, control){__doPostBack('employeeTxb_m',control.values[index]);});
' Code Behind (Sorry that this code is in VB.net):
Private Sub em(ByVal sender As Object, ByVal e As System.EventArgs) Handles employeeTxb_m.TextChanged
Dim empId As Integer = CInt(Request.Params("__EVENTARGUMENT"))
End Sub
'In Page_Load is have this block that is executet each time
' Register employee list javascript variable
Dim sb As StringBuilder = New StringBuilder()
sb.Append("")
sb.Append("var employees_m = [")
For Each dr As DataRow In allEmployeesLookupDt_m.Rows
sb.Append(String.Format("['{0}',{1}],", CStr(dr("EmpName")).Replace("'", "\'"), dr("EmpNo")))
Next
sb.Append("];")
sb.Append("")
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "employeesList_m", sb.ToString().Replace("],];", "]];"))
|
|
|
|
|
Lots of changes have happened in the past few months and looking through the questions this topic has been outdated. Currently, how are we supposed to get the value from a key/value array?
I'm using this at the moment, but it only works the first time something is selected. If you go and erase the text and type something else it doesn't get me the value anymore.
<pre>
<input type='hidden' value="" name="reviewStation">
<input type='text' class="newField" onchange="document.getElementById('reviewStation').value = obj_station.values[0];" style="align:left; width:245px;" value="" name="revStationShow">
<script> var obj_station = new autosuggest("revStationShow", stations_array); </script>
</pre>
Any suggestions? Let me know if you need more clarification.
|
|
|
|
|
Hi,
to get a key:
var key = obj_station.keywords[obj_station.selectedIndex];
to get a value:
var value = obj_station.values[obj_station.selectedIndex];
Hope it helps,
Dmitriy.
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
Perfect! Thank you.
I also chose to modify it a bit. In case anyone wants to see, my code is below:
<input type='hidden' value="<% if toUpdate then %><%= rS1("StationID") %><% end if %>" name="reviewStation">
<input type='text' class="newField" style="align:left; width:245px;" value="" name="revStationShow">
<script>
var obj_station = new autosuggest("revStationShow", stations_array, null, function(index, control)
{
document.getElementById('reviewStation').value = control.values[index];
}
);
</script>
|
|
|
|
|
My implementation uses ajax to retrieve the results, BUT the data is hold in static client-side arrays:
After retrieving the results from database with Ajax, I create the array passing the result and using eval.
This way I can have dinamic list (ajax) of options (autosuggest) with no delay in searches (client-side).
I thought it might be useful to someone else.
|
|
|
|
|
So I have a listbox right below my textbox for which the suggestion is for. When I type something into the textbox the suggestion list comes up, but the very first entry is covered up by the listbox which is right underneath the textbox. Is there some setting to change the viewing of the different html elements? I want the suggestion list to go on top of the listbox.
Here's the code:
<div style="width:250px; float:left; padding-right:10px; ">
<input type='text' class="newField" onchange="document.getElementById('spe').value = obj_spe.values[0];" style="align:left; background:#ffffff; width:220px;" value="" name="speShow">
<script> var obj_spe = new autosuggest("speShow", names_array); </script>
<input type='hidden' value="<% if toUpdate then %><%= rS1("SpecProjEng") %><% end if %>" name="spe">
<% if toUpdate then
rS.Open "SELECT Name, FirstName FROM ReviewUsers WHERE UserID = " & rS1("SpecProjEng") rS.Close
end if
%>
<img src="images/admin.gif" id='butimg' style="cursor:pointer " onClick="window.open('masterUsers.asp?type=SPE', '', 'resizable=1,width=250,height=700,scrollbars=yes,menubar=0');" />
<div class="newFieldTitle"><span class="reqd">*</span><select name="CoordType">
<option value="SPE" <%=SPESelected%>>Option1</option>
<option value="SPC" <%=SPCSelected%>>Option2</option>
<option value="DC" <%=DCSelected%>>Option3</option>
</select>
</div>
</div>
Thanks in advance for your help.
|
|
|
|
|
Hi,
rightnow I don't have a quick solution for you - there is much to change for this to work. I'll try to work on this problem on the weekend.
- Dmitriy.
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
Maybe use iframe instead:
If you have several input/combo boxes on a page, and encounter a situation when a suggestion list is rendered behind one of the other controls, you should change the use_IFrame variable to true. Otherwise, it is recommended to keep it false.
this.use_iframe = true; // should the control use an IFrame element to fix suggestion list positioning (MS IE only)?
Regards
|
|
|
|
|
Did it work (the iframe alternative)?
modified on Monday, June 1, 2009 4:53 PM
|
|
|
|
|
I think it's already set to true. I'll try setting it to false and see what happens. Sorry I didn't get time to try it out today. I will tomorrow. I was looking up on it and I may be able to use iFrames to solve my problem, will try tomorrow. I tried using the z-index for the html elements, but that didn't work. Will keep you updated. Thanks
|
|
|
|
|
|
Ok so setting it to false didn't change anything. I didn't get time to try and implement the iframe stuff, will hopefully get to that Monday.
|
|
|
|
|
Found the problem. It's actually a IE problem with any version less than IE 7. The select box covers any other element included in a DIV tag. So you have to implement a "fix" using an iframe to cover the select box and then put the dropdown suggestion textbox on top of that. This is the solution I'm using if anyone else encounters a problem:
http://www.fabien-molinet.fr/index.php?option=com_content&task=blogsection&id=8&Itemid=9
|
|
|
|
|
Nice. Thanks for the feedback.
As an additional and final suggestion, maybe you could change the order or distribution of the elements in the form, so the autosuggest would not overlap the other element(s) in IE6-.
Regards
modified on Tuesday, June 30, 2009 10:54 AM
|
|
|
|
|
Hi,
I am also facing the same issue.
Did you get any resolution?
Any help will be useful.
Thank,
Aasheesh
|
|
|
|
|
Sorry, I forgot to update this site with my findings. So in my case I just removed the listbox completely from the site and replaced it with check boxes. However, there is a fix built into Internet Explorer 7 or 8, can't remember what I read. If you can't upgrade or want to support older versions, look up IE listbox covered up fix or something along those lines in google. Some people have made up some small javascript patches and other little bits of code to help correct the situation. Basically, you'll need to apply some type of patch to get it to work, because IT IS a bug in Internet Explorer.
If you can't find anything, I'll try to find some of the articles I saw previously, otherwise happy hunting. Hope this helped.
|
|
|
|
|
I have about 700 names that need to be searched through in the array when typing into the textbox. When I limit the list to about 60 names, it works fine, but when I start adding more than 60 names, no list shows up. Do you have any idea what's causing this? I have a feeling it may have something to do with array length limitations, but please do let me know what you think. Thanks
|
|
|
|
|
Good evening,
there is no limit on the number of keywords you can use; I've tested the script with the subset of English Language dictionary (25.000+ terms) and it worked perfectly fine.
What can your problem be: do you see any errors in error console (try Firefox)? My guess is that you've introduced some minor JavaScript syntax error that prevents script from parsing.
Regards,
Dmitriy.
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|