Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i add cascading dropdown

one drop down change it's reflect other.

but output is coming like whn i appen dropdown value.
how can i remove this space between select and username.

Select
// space in dropdown i dont know why.
jaydeep
Rishi
neha

What I have tried:

PageMethods.userlist($('option:selected', this).val(), function (result) {
           $("#UserList").empty();
           $("#UserList").append($("<option>" + 'select' + "<option/>"));
           for (i = 0; i < result.length; i++) {
               $("#UserList").append($("<option value=" + result[i].RC_UserID + "> " + result[i].Username + " </option>"));

           }
       });
Posted
Updated 19-Sep-17 21:52pm
v2

1 solution

correction
$("#UserList").append("<option>" + 'select' + "</option>");


end tag typo </option> not <option/>

follow this pattern to bind the items dynamically, since you are using jquery selector/append in the loop the performance will be low if the items length is more, for every item it will redraw the control items on the UI

var result = ['aaaa','bbbbb','ccccc']
           $("#UserList").empty();
           var html = ["<option>" + 'select' + "</option>"];
        for (i = 0; i < result.length; i++)
            html.push("<option value=" + result[i] + "> " + result[i] + " </option>");
        $("#UserList").html(html.join(''));
 
Share this answer
 
v2
Comments
Jaydeep Shah 20-Sep-17 5:24am    
thank you @Karthik Bangalore
Jaydeep Shah 20-Sep-17 5:25am    
can you please give me my previous problem.

How to click linkbutton using jquery.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900