guys- thanks for the replies.. jake got me started and i ended up with
following.. if anybody can turn it into a "plugin" that takes the
input field's name and the list of tags as parameters, it might be
useful for the community..

    <script type="text/javascript">
    // <![CDATA[
    $(function(){
        $("span.tag").click(function(){
            var input = $("input.tagtext");
            if (input.val().search(new RegExp("\\b"+$(this).text()+"\
\b","i"))===-1) {
                input.val(input.val() + $(this).text() + " ");
                                $(this).addClass("selected");
            }
                        else
                        {
                                input.val(input.val().replace($(this).text() + 
" ", ""));
                                $(this).removeClass("selected");
                        }
            return false;
        });
    });
    // ]]>
    </script>
    <style type="text/css">
        span.tag.selected {background:blue;color:white;padding:2px
6px;cursor:pointer;}
            input.tagtext {width:400px;}
    </style>

Reply via email to