How to remove part of user entered values and append new values to an input box
<p>I have a search box and a suggestion box to show the suggestions.</p>

<p>Once users type something in the search box, the suggestions will appear then user is able to select one of the suggestions to be added to the search input box. After that user will be able to type other terms to receive the suggestions and so on.</p>

<p>I can show the suggestions and add the selected suggestion to the input box <strong>but</strong></p>

<p>lets say user enters f then first is suggested and user choose it, then the input box will be f, first but it should be first only. if I reset the input I will lose the other search terms.</p>

<p>In short: I want to keep all values before the last semicolon and remove all those after the semicolon.</p>

<p><strong>code</strong></p>

<pre><code>&lt;script type="text/javascript"&gt;
    function selectS(value){
        alert("clicked:" + value);
         var curr = $('#term').val();
            if(curr)
                 curr += ";";
            $('#term').val(curr + value);
    }
....

&lt;s:form id="searchForm" method="POST" enctype="multipart/form-data"&gt;
     &lt;s:textfield id="term" name="term" label="Search" onkeyup="find(this.value)"/&gt;
&lt;/s:form&gt;
</code></pre>
