Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,

I have one asp.net dropdown control in popup. Suppose i have 3 options in dropdown like Chair 1, Chair 2 and CHair 3. I want to select dropdown item by text.

Its showing as selected but its still displaying first item not the selected one.

Please help very urgent.

Thanks,
Tiru
Posted
Comments
Please post the code.
Jenno Richi 27-Nov-13 2:46am    
can you please put your code ?

Hi Raghava,

I hope my code can help you out....

JavaScript
$('#DropDownList1').find('option').each(function(i,n){
    if($(n).text()=='Item 5')
    {
        $(n).attr('selected','selected');
    }
    else
    {
        $(n).removeAttr('selected')
    }
});
 
Share this answer
 
hi Murali,

Thanks for your reply

what is i and n here ? and how do i pass dropdown value to be selected?
 
Share this answer
 
Comments
This is not an answer. Please delete this and if you want to reply to any answer, then click on "Have a Question or Comment" in that Answer Box itself.

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