hello everybady ,
i have label called project title and beside it drop down list and text box .. i used the code below so user can search inside the text box for specific project title .. and there is search button so after user select , he should press search button to get pdf file .. the problem that when user first time write gas inside text box , he will get for example three option (gas project , gas and oil project, aluminum and gas project) then he click search and he will get the result , but after that if he write gas he will get the result duplicated as (gas project , gas and oil project, aluminum and gas project,gas project , gas and oil project, aluminum and gas project) , third time the result will be duplicated 3 times and so on .... plz help me where should i modify the code?
asp:TextBox ID="Textsearch" runat="server" Width="198px"
onkeyup = "FilterItems(this.value)"></asp:TextBox>
<br />
<asp:Label ID="Label6" runat="server" BackColor="#A8923B" Font-Size="13pt"
ForeColor="White" Height="24px"
Style="font-size: 13pt; background-position: center center; border-left-color: darkgreen; border-bottom-color: darkgreen; vertical-align: top; border-top-style: outset; border-top-color: darkgreen; background-repeat: repeat-y; border-right-style: outset; border-left-style: outset; text-align: left; border-right-color: darkgreen; border-bottom-style: outset;"
Text="Project_Title:" Width="121px"></asp:Label>
<asp:DropDownList ID="DropDownList5" runat="server"
AppendDataBoundItems="True" Height="20px" style="margin-bottom: 0px"
Width="300px" EnableTheming="True"
DataSourceID="SqlDSC" DataTextField="Project_Title"
DataValueField="Project_Title" >
<asp:ListItem Selected="True" Text="(Choose A Project Title)" Value=""></asp:ListItem>
</asp:DropDownList>
<script type = "text/javascript">
var DropDownList5Text, DropDownList5Value, DropDownList5, Label6;
function CacheItems() {
DropDownList5Text= new Array();
DropDownList5Value = new Array();
DropDownList5 = document.getElementById("<%=DropDownList5.ClientID %>");
Label6 = document.getElementById("<%= Label6.ClientID%>");
for (var i = 0; i < DropDownList5.options.length; i++) {
DropDownList5Text[DropDownList5Text.length] = DropDownList5.options[i].text;
DropDownList5Value[DropDownList5Value.length] = DropDownList5.options[i].value;
}
}
window.onload = CacheItems;
function FilterItems(value) {
DropDownList5.options.length = 0;
for (var i = 0; i < DropDownList5Text.length; i++) {
if (DropDownList5Text[i].toLowerCase().indexOf(value) != -1) {
AddItem(DropDownList5Text[i], DropDownList5Value[i]);
}
}
Label6.innerHTML = DropDownList5.options.length + " Project Title";
if (DropDownList5.options.length == 0) {
AddItem("No items found.", "");
}
}
function AddItem(text, value) {
var opt = document.createElement("option");
opt.text = text;
opt.value = value;
DropDownList5.options.add(opt);
}
</script>