Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3286344
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:22:09+00:00 2026-05-17T20:22:09+00:00

I have two listboxes set with multiple property and on adding the items from

  • 0

I have two listboxes set with multiple property and on adding the items from first to second, I don’t want the selection on the second listbox.

I wrote the code like this

$("#<%=lbCommcatTo.ClientID%> option").removeAttr("selected");

It worked in IE7 but not in IE6. Can anyone please give me a solution?

The html is

<table cellspacing="0" cellpadding="0" width="100%" border="0">
    <tr>
        <td width="45%">
            <div style="height: 230px;width: 234px; overflow: auto; border: solid 1px #c1c1c1" id="dvLeft" runat="server">
                 <select id="lbCommcatFrom" runat="server" style="height:790px;" multiple name="lbCommcatFrom" class="ContentTextNormal">
                 </select>
             </div>
         </td>
         <td width="10%" align="center">
             <div style="border: solid 1px #6E6E6E; width: 20px; height: 20px; padding-top: 4px; text-align: center; margin-bottom: 5px; background-color: #CECFBE; cursor: pointer" title="Add to List" id="imgMoveRight" class="clsArrow">
             </div>
             <div style="border: solid 1px #6E6E6E; width: 20px; height: 20px; padding-top: 4px; text-align: center; background-color: #CECFBE; cursor: default" title="Remove from List" id="imgMoveLeft" class="clsArrow">
             </div>
           </td>
           <td width="45%">
               <div style="height: 230px;width: 234px; overflow: auto; border: solid 1px #c1c1c1" id="dvRight" runat="server">
                   <select id="lbCommcatTo" runat="server" style="height:230px;width:234px" multiple name="lbCommcatTo" class="ContentTextNormal">
                   </select>
                </div>
            </td>
        </tr>
    </table>

and the script goes like this

$("#imgMoveRight").click(function(){   
                 $("#<%=lbCommcatFrom.ClientID%>  option:selected").appendTo("#<%=lbCommcatTo.ClientID%>");     

                 if( $("#<%=lbCommcatFrom.ClientID%> option").length == 0)
                 {
                        $("#<%=lbCommcatFrom.ClientID%>").parent().css("overflow-x","hidden");
                        $("#<%=lbCommcatFrom.ClientID%>").parent().css("overflow-y","hidden");                         
                        $("#<%=lbCommcatFrom.ClientID%>").css("width","234px");
                        $("#<%=lbCommcatFrom.ClientID%>").css("height","230px");
                        $(this).css("cursor","default");                          
                 }  
                 else
                 {
                     if($("#<%=lbCommcatTo.ClientID%> option").length > 0)
                     {                       
                         $("#<%=lbCommcatTo.ClientID%>").parent().css("overflow-x","scroll");  
                         $("#<%=lbCommcatTo.ClientID%>").css("width","465"); 
                         $("#<%=lbCommcatFrom.ClientID%>").css("width","465"); 
                         if($("#<%=lbCommcatTo.ClientID%> option").length > 15)
                         {
                             $("#<%=lbCommcatTo.ClientID%>").css("height",$("#<%=lbCommcatTo.ClientID%> option").length * 18);    
                             $("#<%=lbCommcatTo.ClientID%>").parent().css("overflow-y","scroll");  
                         } 
                         else
                         {
                            $("#<%=lbCommcatTo.ClientID%>").css("height","230");
                            $("#<%=lbCommcatTo.ClientID%>").parent().css("overflow-y","hidden");  
                         } 

                         $("#imgMoveLeft").css("cursor","pointer");                    
                     }                     
                 }   
                **$("#<%=lbCommcatTo.ClientID%> option").removeAttr("selected");**              



            });

            $("#imgMoveLeft").click(function(){

                 $("#<%=lbCommcatTo.ClientID%> option:selected").appendTo("#<%=lbCommcatFrom.ClientID%>");
                 $("#<%=lbCommcatFrom.ClientID%>").css("width","465");                  
                 if( $("#<%=lbCommcatTo.ClientID%> option").length == 0)
                 {
                        $("#<%=lbCommcatFrom.ClientID%>").parent().css("overflow","scroll"); 
                        $("#<%=lbCommcatTo.ClientID%>").parent().css("overflow-x","hidden");
                        $("#<%=lbCommcatTo.ClientID%>").parent().css("overflow-y","hidden");                           
                        $("#<%=lbCommcatTo.ClientID%>").css("width","232px");
                        $("#<%=lbCommcatTo.ClientID%>").css("height","230px");
                        $(this).css("cursor","default"); 
                 }  
                 else
                 {
                     if($("#<%=lbCommcatFrom.ClientID%> option").length > 0)
                     {                         
                         $("#<%=lbCommcatFrom.ClientID%>").parent().css("overflow-x","scroll");  
                         if($("#<%=lbCommcatFrom.ClientID%> option").length > 15)
                         {
                             $("#<%=lbCommcatFrom.ClientID%>").css("height",$("#<%=lbCommcatFrom.ClientID%> option").length * 16);    
                             $("#<%=lbCommcatFrom.ClientID%>").parent().css("overflow-y","scroll");  
                         } 
                         else
                         {
                            $("#<%=lbCommcatFrom.ClientID%>").css("height","230");
                            $("#<%=lbCommcatFrom.ClientID%>").parent().css("overflow-y","hidden");  
                         }  
                         $("#imgMoveRight").css("cursor","pointer");     
                     }                     
                 }

                 **$("#<%=lbCommcatFrom.ClientID%> option").removeAttr("selected");**
            });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:22:10+00:00Added an answer on May 17, 2026 at 8:22 pm

    You can try using “attr”

    $("#<%=lbCommcatTo.ClientID%> option").attr("selected", "");
    

    [Source]

    Have a look here: [Link] more specifically read that:

    If you wrap the code that sets selected in a setTimeout it works, surprisingly enough.
    I have to assume it needs to give control back to the browser to let state settle.
    
    Another way to get this to work is to wrap the code that sets selected in a try/catch 
    block and just swallow the error from IE. It seems to set the element as selected properly 
    despite the error!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My scenario is this: I have two listbox's, one that contains all my database
My WPF Listbox should have two columns. The one on the right should have
I have a page with two ListBox controls. The page contains a list of
I have two collections displayed in my WPF application, and I'd like to have
I need a single scrollable surface that contains two bound lists. At first, I
I have a List<ColumnList> ColumnListLists which has a binding source (bsLists) attached to it.
I'm writing an app where users enter records. I have a class that represents
For my site, I have a list of users and a list of events.
I have a WPF program built in C#, and part of it's function is
You can only have one form runat=server per page apparently. My page has one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.