jquery autocomplete extra spaces

Posted by elasticrash on Stack Overflow See other posts from Stack Overflow or by elasticrash
Published on 2011-01-17T15:43:58Z Indexed on 2011/01/17 15:53 UTC
Read the original article Hit count: 133

Filed under:
|
|

I got this loop in a jsp file

<%    for (int i = 0; i < length; i++)
                 {
                    for( int j = 0; j < width; j++)
                    {
                        element = MAP_LIST[j][i];
                        if (element.equals("A"))
                        {} else if (j == width-1 && i == length-1){
                        %>
                        <%=element%><%}
                        else
                        {
                        %>
                        <%=element%>,<%}
                    }
                 } 
%>

which gets me a csv list from an oracle database for my autocomplete text field by using jquery

function Mapsheets(type,nomos)
{   
    $(function() {
        var f_data;

        $.get('/gaec_web/MapSheets.jsp',{'datasrc-select':datasource, 'type_1': type, 'nomos': nomos}, function(data){
            f_data = data.split(',');
        $( "#fx_no" ).autocomplete({
            source: f_data,
            minLength: 2
        });
        });
            });
}

everything works like a charm, i type the first 2 chars and the autocomplete pops up displays every thing as it was supposed to and when I try to pick a value i get the value with several (5) extra spaces in the tail. And then when it gets submitted it fails cause it doesnt match the mapname in question. the results look like this

"     320-197"

So what is causing this? if i run the jsp page alone also get normal results for example

372-146, 376-146, 372-149, 368-149, 376-149, 380-149, 380-152, 376-152, 372-152, 368-152, 368-155, 376-155, 372-155, 380-155, 368-158, 380-158, 376-158, 372-158

thanks in advance

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery