0

I m using jquery UI for getting suggestions of friend names and id, but the problem is I am not able to pass user id using autocomplete json function .

        $(function() {


    function split( val ) {
        return val.split( /,\s*/ );
    }
    function extractLast( term ) {
        return split(term).pop();
    }

    $( "#recipient" )
        // don't navigate away from the field on tab when selecting an item
        .bind( "keydown", function( event ) {
            if ( event.keyCode === $.ui.keyCode.TAB &&
                    $( this ).data( "autocomplete" ).menu.active ) {
                event.preventDefault();
            }
        })
        .autocomplete({
            source: function( request, response ) {
             var attm= $('.USERID').val();
                $.getJSON( "modules/messages/sql.php", {
                    term: extractLast( request.term ),

                }, response );
            },
            search: function() {
                // custom minLength
                var term = extractLast( this.value );
                if ( term.length < 2 ) {
                    return false;
                }
            },
            focus: function() {
                // prevent value inserted on focus
                return false;
            },
            select: function( event, ui ) {
                var terms = split( this.value );
                // remove the current input
                terms.pop();
                // add the selected item
                terms.push( ui.item.value );
                // add placeholder to get the comma-and-space at the end
                terms.push( "" );
                this.value = terms.join( ", " );
                                 var prollNos = $('#recipientid').val()
            $('#recipientid').val(prollNos + ui.item.id + ", ");
                return false;
            }
        });
});

in which i am trying to pass a: $('.USERID').val() as user id , can anyone help me out?

2
  • 1
    Where is $('.USERID').val() coming from? More code please. Commented Jun 7, 2012 at 23:43
  • m getting a value USERID from a hidden field via jquery val() Commented Jun 8, 2012 at 15:11

1 Answer 1

1

I achieve something similar by GET. I use jquery-ui-autocomplete, as source I use: "source.php?param=something". So the final request my source page gets is "source.php?param=something&term=blabla"

Sign up to request clarification or add additional context in comments.

1 Comment

with some modifications this method worked , thanks for helping out frnd

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.