Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ajax search

Status
Not open for further replies.

kevin197

Programmer
Mar 21, 2002
88
GB
I've been told I'd get more help here than on the ajax tread so here goes :)

I have a search box that works fine using ajax by clicking on the suggested search term it brings up and then clicking the go button.What I'm looking for now is to make this a one click process instead of two.I would like the search to trigger once the user clicks on the suggested term instead of needing the go button clicked after. Am I right in thinking that this can be done some how using the javascript onclick command or not?

So far I have:

Code:
<div id="Top1_yel" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'Top1_imgBtnSearch')">

<span id="Top1_lblLoginName" class="BodyText" style="font-weight:bold;"></span><p>

<span class="q">Quick search:</span>

<input name="Top1$txtQuickSearch" type="text" value="keywords or code" id="Top1_txtQuickSearch" tabindex="1" class="BodyText" AutoComplete="Off" OnFocus="Javascript:document.getElementById('Top1_txtQuickSearch').value = ''" />

<input type="image" name="Top1$imgBtnSearch" id="Top1_imgBtnSearch" tabindex="2" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Top1_imgBtnSearch','','im/go.gif',1)" src="im/go_2.gif" style="border-width:0px;" />

<a id="Top1_hpAZ" class="RedText" href="AToZIndex.aspx">A-Z Index</a>

</p>

<script type="text/javascript">

//<![CDATA[

Sys.WebForms.PageRequestManager._initialize('Top1$ToolkitScriptManager1', document.getElementById('Form1'));

Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tUpdatePanel1'], ['rptTable'], [], 90);	//]]>

</script>

</div>
 
It is very hard to tell from this code, and you haven't provided a working example, but I'd suggest calling the form's submit event immediately after you call the code that populates the text box.

----
 
Thanks cLFlaVA

Here is the code I think you need:

Code:
<asp:Panel ID="yel" runat="server" DefaultButton="imgBtnSearch">
<asp:Label ID="lblLoginName" runat="server" CssClass="BodyText" Font-Bold="True"></asp:Label><p>
<span class="q">Quick search:</span>
<asp:TextBox ID="txtQuickSearch" runat="server" CssClass="BodyText" AutoComplete="Off" TabIndex="1">keywords or code</asp:TextBox>
<asp:ImageButton ID="imgBtnSearch" runat="server" ImageUrl="~/im/go_2.gif" CausesValidation="False" TabIndex="2"></asp:ImageButton>
<asp:HyperLink ID="hpAZ" runat="server" NavigateUrl="~/AToZIndex.aspx" Text="A-Z Index" CssClass="RedText"></asp:HyperLink>
</p>
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</cc1:ToolkitScriptManager>

<cc1:AutoCompleteExtender ID="AutoCompleteEx" runat="server" 
CompletionInterval="20" 
CompletionListCssClass="srchSuggest" 
CompletionListHighlightedItemCssClass="srchSugLIA" 
CompletionListItemCssClass="srchSugLI" 
CompletionSetCount="20" 
DelimiterCharacters=";, :" 
EnableCaching="true" 
MinimumPrefixLength="2" 
ServiceMethod="GetSuggestList" 
ServicePath="~/SearchService.asmx" 
TargetControlID="txtQuickSearch" >
</cc1:AutoCompleteExtender>

<%--<cc2:AutoCompleteExtraExtender ID="AutoCompleteEx_" runat="server" 
    CompletionInterval="20" 
    CompletionListCssClass="srchSuggest" 
    CompletionListHighlightedItemCssClass="srchSugLIA" 
    CompletionListItemCssClass="srchSugLI" 
    CompletionSetCount="20" 
    DelimiterCharacters=";, :" 
    EnableCaching="false" 
    MinimumPrefixLength="2" 
    ServiceMethod="GetCompletionList"     
    TargetControlID="txtQuickSearch" 
    OnItemSelected="test" 
    AsyncPostback="false" UseContextKey="True" AutoPostback="true" >
</cc2:AutoCompleteExtraExtender>--%>

</asp:Panel>
</div>

I think this onclick code needs to go after the AutoPostback="true" > but I'm not sure.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top