Click here to Skip to main content
15,889,861 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys, My requirement is two CheckBoxList with same Data. in First CheckBoxList if i check the Item then automatically removes the Second CheckboxList Item. as well as if i uncheck the item in first CheckBoxList and automatically adding into second checkboxList.

Please any one help me..
Posted
Updated 5-Nov-12 1:29am
v2
Comments
njammy 5-Nov-12 11:24am    
It sounds like you are trying to build a item selector control? Correct me if I'm wrong but I understand you want to add/remove items from one list to another?
Sandeep Mewara 5-Nov-12 14:18pm    
Odd control usage for such feature implementation :doh:

Why not use two listbox with items from one to other or back?

1 solution

you can do it by using clone() and html() method.

eg.

JavaScript
$(function(){
//on check of ist checkboxlist event do this create a new list except checked data in ist list.

// copy all data except checked in ist list
(
var tempSecListString = "<select id="secId">";

// for each data create a loop 
$("data").each(funtion(){
if(!$(this).is(:checked)){
tempSecListString + = "<option value=""+ $(this).val()+ ""></option>"
}
});
tempSecListString + = "</select>";
var $htmlElement = $(tempSecListString);
$("#secId").html($htmlElement);
)

});

in my suggestion
Its suicidal to do this, if you can move this code to server side just do it :-D
 
Share this answer
 

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