Difference between revisions of "Complex Tables Favlet"

From Level Access Web Labs
Jump to navigation Jump to search
Line 5: Line 5:
  
 
</html>
 
</html>
 +
Sample code
 +
<code>
 +
javascript:(function(){
 +
 +
var el = document.querySelectorAll('td, th'); 
 +
 +
var str;
 +
var headers=[];
 +
var sentinel;
 +
 +
if (el.length>0) {
 +
for (var i=0; i<el.length; i++) {
 +
if (el.item(i).hasAttribute('headers')) {
 +
str = el.item(i).getAttribute('headers');
 +
headers = str.split(' ');
 +
for (var ii=0; ii < headers.length; ii++) {
 +
if (document.getElementById(headers[ii])) {
 +
sentinel = 1;
 +
s = document.createElement('Span');
 +
t = document.createTextNode(document.getElementById(headers[ii]).textContent+" ");
 +
s.appendChild(t);
 +
s.style.backgroundColor = 'antiqueWhite';
 +
s.style.color = 'black';
 +
el.item(i).appendChild(s);
 +
}
 +
}
 +
 +
}
 +
str='';
 +
header='';
 +
t='';
 +
}
 +
if (!sentinel) {
 +
  alert('no valid headers found');
 +
}
 +
}
 +
else {
 +
  alert('No table cells found');
 +
}
 +
 +
})();
 +
</code>
 
[[Category:Favlet]]
 
[[Category:Favlet]]

Revision as of 02:23, 5 February 2014

Right click or press the applications key on this link. Choose Add to Favorites or Add to Bookmarks to add this Favlet to your Favorites or Bookmarks. Complex Tables Favlet Sample code javascript:(function(){

var el = document.querySelectorAll('td, th');

var str; var headers=[]; var sentinel;

if (el.length>0) {

	for (var i=0; i<el.length; i++) {

if (el.item(i).hasAttribute('headers')) { str = el.item(i).getAttribute('headers'); headers = str.split(' '); for (var ii=0; ii < headers.length; ii++) { if (document.getElementById(headers[ii])) { sentinel = 1; s = document.createElement('Span'); t = document.createTextNode(document.getElementById(headers[ii]).textContent+" "); s.appendChild(t); s.style.backgroundColor = 'antiqueWhite'; s.style.color = 'black'; el.item(i).appendChild(s); } }

} str=; header=; t=; } if (!sentinel) { alert('no valid headers found'); } } else {

 alert('No table cells found');

}

})();