I, also, am not entirely sure what the end requirement is, but this might help ...
$(document).ready(function() { var inputUpdate = $('input.listcomplete').next('ul').find('li') .bind('click', function(){ //this only works when a space is a valid separator, ie no LI //text contains spaces! var curVal = inputUpdate.val().split(/\s+/) , liText = $.trim($(this).text()) , indx = $.inArray(liText, curVal); if(indx < 0){ curVal.push(liText); }else{ curVal = $.grep(curVal, function(v,i){ return (v!=liText); }); } inputUpdate.val($.trim(curVal.join(' '))); }).end().end(); }); On May 20, 9:32 pm, Scott Sauyet <[EMAIL PROTECTED]> wrote: > nos wrote: > > <input name="Categories" class="listcomplete" value="Cat1 Cat2 Cat3"> > > <ul> > > <li>Cat1</li> > > <li>Cat2</li> > > <li>Cat3</li> > > <li>Cat4</li> > > <li>Cat5</li> > > </ul> > > I'm not quite sure what you're looking to do, and this markup is part of > the issue. There is no "type" attribute on your "input" tag. Is this > just a text field? Also, the tag is also not closed. Is the "ul" > element supposed to somehow be embedded in the "input" element? > > -- Scott