Hello All,

Just about getting feet wet with jQuery, wrote a simple function which
fills an input field with text of the link clicked after sorting the
comma separated values. It is working as expected but would like to
know if it can be made more comprehensive.

$(document).ready(
    function(){
        $('a.taglink').click(
                function(){
                    tagSelect(this.text);
                    return false;
                }
        )

    }
);

function tagSelect(f){

    if(!$('#tags').val()){
            $('#tags').val(f);
            return false;
    }

    var substrings = $('#tags').val().split(f);

    if (substrings.length <= 1){
            $('#tags').val($('#tags').attr('value')+',' +f);
            var wordsArr = $('#tags').val().split(",");
            wordsArr.sort();
            $('#tags').val(wordsArr.join());
    }
    return false;
}


Thanks in advance
Tarique

-- 
=============================================================
PHP Applications for E-Biz: http://www.sanisoft.com
Cheesecake-Photoblog: http://cheesecake-photoblog.org
=============================================================

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to