Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom search VisualForce page. I have an inputText area for a search term, upon hitting enter I wan't to pass that value to URL parameter. Trying to do it via JavaScript.

I want URL to be apex/pageName?s=ValueEnteredInSearchBox

This is what I have right now which isn't working.

<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;"
                        <script type="text/javascript">
                            function insertSearchParam() {
                                var val = document.getElementById("{!$Component.searchinput}").value;
                       = "?s=" + val;
                            document.getElementById("{!$Component.searchinput}").onkeypress = function (e) {
                                if (!e) e = window.event; // resolve event instance
                                if (e.keyCode == '13') {
                                    return false;
share|improve this question

Best bet is a form using GET method.

  <form method="GET">
    <input name="s" value="ValueEnteredInSearchBox" type="text" />
    <input type="submit" />

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.