我有一个自定义搜索VisualForce页面。我有一个搜索词的inputText区域,点击输入后我不想将该值传递给URL参数。试图通过JavaScript来实现。
我希望网址是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>
答案 0 :(得分: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;
}