Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Created November 28, 2011 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterdavis/1400781 to your computer and use it in GitHub Desktop.
Save walterdavis/1400781 to your computer and use it in GitHub Desktop.
var outer = $('theOuterBox');
var comp = $('theComparisonArea').update();
//you shouldn't need to change anything below this
var list = outer.childElements();
document.observe('click', function(evt){
var elm;
if(elm = evt.findElement('input[type="checkbox"]')){
if((outer.select('input:checked').length + comp.select('input:checked').length) > 2){
evt.stop();
elm.checked = false;
}else{
comp.select('div').each(function(em){
outer.insert(em.remove());
});
list.each(function(em){
if(em.down('input:checked')){
comp.insert(em.remove());
}
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment