Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
95
rated 0 times [  102] [ 7]  / answers: 1 / hits: 15722  / 12 Years ago, sat, june 16, 2012, 12:00:00

Hello everybody I am drawing dynamic table and I want to add header for table how to add header to dynamic table here is my table code:



$.get('http://myDomain.com/RIA/topIndiaDetails.asp', function(data)
{
console.log(####+data);

var up = new Image();
var down = new Image();

up.src = ../../jquery.mobile/images/up.png;
down.src = ../../jquery.mobile/images/down.png

substr = data.split('$');

//alert(substr.length);
//var theader = '<table border=1>n';
//<table id=auditOverview border=1>
var theader = '<table border=1 id=tableId>n';
var tbody = '';

for (var out = 1;out<substr.length-1;out++)
{
//alert(substr[out]);
tbody += '<tr>';
var pra = substr[out].split('|^');
//alert('pra.length is: '+pra.length);

for (var i=0;i<pra.length-1;i++)
{
tbody += '<td>';

if (pra[i]==Red)
{
pra[i].append(<img id='theImg' src='../../jquery.mobile/images/down.png'/>);
}
else if (pra[i]==Green)
{
pra[i].append(<img id='theImg' src='../../jquery.mobile/images/up.png'/>);
}
tbody += pra[i];
tbody += '</td>'
}
tbody += '</tr>n';
}
var tfooter = '</table>';
document.getElementById('wrapper').innerHTML = theader + tbody + tfooter;

});


Any help will be appreciated. Thanks in advance.


More From » jquery

 Answers
4

if I could get your point correctly



DEMO: http://jsfiddle.net/75zFX/8/



var colheader = '<tr><th>Column1</th><th>Column2</th> .....</tr>n';
var tbody = colheader ;// and replace with var tbody = '';

[#84865] Thursday, June 14, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tomas

Total Points: 165
Total Questions: 111
Total Answers: 103

Location: Maldives
Member since Tue, Dec 21, 2021
2 Years ago
tomas questions
Thu, Jan 27, 22, 00:00, 2 Years ago
Mon, May 10, 21, 00:00, 3 Years ago
Tue, Jan 5, 21, 00:00, 3 Years ago
;