0

我有一个自定义搜索 VisualForce 页面。我有一个用于搜索词的 inputText 区域,按回车后我不想将该值传递给 URL 参数。试图通过 JavaScript 来实现。

我希望 URL 是 apex/pageName?s=ValueEnteredInSearchBox

这就是我现在所拥有的,它不起作用。

<body id="bodyPortalCaseSearch">
    <apex:form id="frmPortalCaseSearch">
        <apex:pageBlock id="pbPortalCaseSearch">
            <div class="table">
                <div class="tableRow">
                    <div id="searchDiv" class="tableCell">
                        <apex:inputText id="searchinput" style="width:85%; height:25px;margin:0; padding: 0px 6px 0px;"
                        title="Portal_Search_Phrase" value="{!portalSearchModel.searchTerm}" onkeypress="insertSearchParam()"
                        />
                        <apex:commandLink id="goSearch" title="Search" style="text-decoration:none;"
                        rerender="asQuestions,asAnswers,asSolutions,asIdeas,asCases,asContent">Search</apex:commandLink>
                        <script type="text/javascript">
                            function insertSearchParam() {
                                var val = document.getElementById("{!$Component.searchinput}").value;
                                document.location.search = "?s=" + val;
                                searches();
                            }
                            document.getElementById("{!$Component.searchinput}").onkeypress = function (e) {
                                if (!e) e = window.event; // resolve event instance
                                if (e.keyCode == '13') {
                                    insertSearchParam();
                                    return false;
                                }
                            }
                        </script>
4

1 回答 1

0
<apex:commandLink action="{!addParameter}" id="goSearch" title="Search" style="text-decoration:none;"rerender="asQuestions,asAnswers,asSolutions,asIdeas,asCases,asContent">Search</apex:commandLink>



 public Pagereference addParameter(){
            ApexPages.currentPage().getParameters().put('s',portalSearchModel.searchTerm);
            return null;
         }
于 2013-01-29T08:21:58.407 回答