PROMOTE MY BLOG: JUST CLICK BELOW BUTTON

Search Any Paper On This Blog

Tuesday, January 17, 2012

::: vuaskari.com ::: CS101 assignment 4 idea for adding tables to HTML from java script

document.write became obsolete for use in web pages when Netscape 4 dies (approximately 2005) so any script intended to run in a web page that uses document.write should have been rewritten around 6 or 7 years ago to get rid of thiose statements. The document.write statement only works in certain situations and can easily cause script clashes and broken web pages. The modern replacements can be completely unobtrusive and the page will still work properly with JavaScript disabled.

If you are interested in how you should be adding tables to HTML from JavaScript then the example that I just uploaded to http://javascriptexample.net/domtable12.php shows you the JavaScript commands needed to add a table into HTML in a completely unobtrusive manner. It doesn't generate the exact multiplication table from the assignment that the various threads here are asking about but the principle is the same - only the number of columns and rows and the table content is different.

 

Javascript code for table:

 

(function() {

var tabl, row, i, j;

tabl = document.createElement('table');

tabl.createTHead();

row = tabl.tHead.insertRow(-1);

row.insertCell(0); row.cells[0].innerHTML = ' ';

for (i=1; i < 13; i++) {row.insertCell(i); row.cells[i].innerHTML = i;}

tabl.appendChild(document.createElement('tbody'));

for (j=1; j < 13; j++) {

   row = tabl.tBodies[0].insertRow(-1);

   row.insertCell(0); row.cells[0].innerHTML = j;

   row.cells[0].className = 'first';

   for (i=1; i < 13; i++) {row.insertCell(i); row.cells[i].innerHTML = i*j;}

}

document.getElementById('mult').appendChild(tabl);

})();



--
Regards
Zeeshan Ahmad
MBA(MIS) Completed
Always remember me in your prayers.
"You can close your eyes to things you don't want to see, but you can't close your heart to the things you don't want to feel."

"Never tell your problems to anyone...20% don't care and the other 80% are glad you have them."




--
We say, "Be one as Pakistani Nation and grow up for Pakistan's Future". Wish you all the best. Join www.vuaskari.com,
To post to this group, send email to vuaskari_com@googlegroups.com
Visit these groups:
This (Main) Group:http://groups.google.com/group/vuaskari_com?hl=en?hl=en
MIT/MCS Group: http://groups.google.com/group/vu_askarimit?hl=en?hl=en
HRM Group: http://groups.google.com/group/askari_hrm?hl=en?hl=en
Banking Group: http://groups.google.com/group/askari_banking?hl=en?hl=en
Management: https://groups.google.com/group/vuaskari_mgt?hl=en
Marketing: https://groups.google.com/group/vuaskari_mkt?hl=en
MIS Group: http://groups.google.com/group/askari_mis?hl=en

No comments:

Post a Comment

PLEASE COMMENT ABOUT YOUR VISIT AND MY SITE

Note: Only a member of this blog may post a comment.