Hi Guys, I need help~~~~
function ddlSuburbs_onClick() {
var listBox = document.getElementById('<%= ddlSuburbs.ClientID %>');
var textbox = document.getElementById('<%= txbSuburb.ClientID %>');
var totalContent = textbox.value.split("; "); if (textbox.value == '') {
textbox.value = listBox.options[listBox.selectedIndex].text;
}
else {
for (var i = 0; i < totalContent.length; i++) {
if (totalContent[i] == listBox.options[listBox.selectedIndex].text) {
return false;
}
}
textbox.value += "; " + listBox.options[listBox.selectedIndex].text;
}
return false;
}
And this is the drop down list:
<select id="ddlSuburbs" runat="server" multiple class="suburbs"
onclick="return ddlSuburbs_onClick()" visible="false" >
</select>
<asp:TextBox
CssClass="long" id="txbSuburb" runat="server" ></asp:TextBox>
Now, I have just used this Auto Suggest plugin, which is pretty cool:
http://code.drewwilson.com/entry/autosuggest-jquery-plugin
The thing is, Auto Suggest now works, but I still wanna keep this drop down list working for users where they can just click on a suburb and it gets inserted into the textbox. Does anyone know how I could archieve this?
I have the JQuery script as:
$(document).ready(function() {
$("#<%=txbSuburb.ClientID %>").autoSuggest("/GetSuburbs.ashx",
{ selectedItemProp: "name", searchObjProps: "name", asHtmlID:"suburbs" });
});