$(".container #topTemplate td:not(.verticalLine)").click(function(element){ if($(element.target).hasClass('selected')){ $(element.target).removeClass('selected') }else{ $(element.target).addClass('selected') } clickAction(); }) $(".container #bottomTemplate td:not(.verticalLine)").click(function(element){ if($(element.target).hasClass('selected')){ $(element.target).removeClass('selected') }else{ $(element.target).addClass('selected') } clickAction(); }) function clickAction(){ var topElement = $("#topTemplate").children(); var bottomElement = $("#bottomTemplate").children(); var topLeftArr=[]; var topRightArr=[]; var bottomLeftArr=[]; var bottomRightArr=[]; for(var i=0;i0 || topRightArr.length >0){ displayContent +=""; if(bottomLeftArr.length >0 && bottomLeftArr.length > topLeftArr.length){ for(var i=0;i0 ){ for(var i=0;i"; } } displayContent +=""; if(topRightArr.length >0){ for(var i=0;i"; } displayContent +=""; } } displayContent +=" "; if(bottomLeftArr.length >0 || bottomRightArr.length >0){ displayContent +=""; if(topLeftArr.length>0 && topLeftArr.length > bottomLeftArr.length){ for(var i=0;i0 ){ for(var i=0;i"; } } displayContent +=""; if(bottomRightArr.length >0){ for(var i=0;i"; } displayContent +=""; } } displayContent +=""; $(".display").css("display","block") $(".display").append(displayContent) } function callbackdata(){ var displayTopRow = document.getElementById("displayTop"); var leftTop =""; var rightTop =""; if(displayTopRow !=null){ var topLen = displayTopRow.cells.length; var topRow = displayTopRow.cells; var temp =""; for(var i=0;i