javascript - How to remove part of user entered values and append new values to an input box -


i have search box , suggestion box show suggestions.

once users type in search box, suggestions appear user able select 1 of suggestions added search input box. after user able type other terms receive suggestions , on.

i can show suggestions , add selected suggestion input box but

lets user enters f first suggested , user choose it, input box f, first should first only. if reset input lose other search terms.

in short: want keep values before last semicolon , remove after semicolon.

code

<script type="text/javascript">     function selects(value){         alert("clicked:" + value);          var curr = $('#term').val();             if(curr)                  curr += ";";             $('#term').val(curr + value);     } ....  <s:form id="searchform" method="post" enctype="multipart/form-data">      <s:textfield id="term" name="term" label="search" onkeyup="find(this.value)"/> </s:form> 

i think want auto complete javascript ui

see http://jqueryui.com/autocomplete/#multiple ...

it allows multiple select in search box.

if reason dont want use it.. can use below code

 function split( val ) {       return val.split( /;\s*/ );     }  function selects(value){         alert("clicked:" + value);          var curr = split($('#term').val());          // remove current input           curr.pop();                     // add selected item           curr.push( value );          // add placeholder comma-and-space @ end           curr.push( "" );           $('#term').val(curr.join( "; " ););     } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -