I have a custom search page for use in Customer Portal.
VF Page:
<form name="frmSearch">
<input type="text" name="keyword" id="keyword" value="{!portalSearchModel.searchTerm}" onkeypress="return noenter(event);" style="width:25%; height:25px;margin:0; padding: 0px 6px 0px;" placeholder="What are you looking for?" />
<input type="button" id="btnSearch" name="btnSearch" value="Search" onclick="searchTerm()" class="go-we3" />
</form>
<script type='text/javascript'>
function searchTerm(){
var searchTerm = document.getElementById("keyword").value;
var url="/apex/PortalSearch?s="+searchTerm;
window.location = url;
return false;
}
</script>
Is there a way to call this apex method in Controller on button click along with the JavaScript?
public void logSearchTerm(){
portalSearchModel.searches();
Search_Log__c sl = new Search_Log__c();
sl.search_term__c = portalSearchModel.searchTerm;
sl.user__c = UserInfo.getUserId();
insert sl;
}