Solved

insertCell not working in Firefox

Posted on 2010-09-01
3
615 Views
Last Modified: 2013-12-07
Ok, here is probably a very easy question that I am completely spacing on.  I am trying to create a script that will dynamically create a table with Javascript.

function ins_row(tab) {
	newRow = tab.insertRow(-1);
}

function add_data(tab, val, spn, lnk, bld, clr) {
	if(val !== 0 && isEmpty(val)) {
		val = " ";
	}
	lstRow = tab.rows.length - 1;
	newCell = tab.rows[lstRow].insertCell(-1);
	if(!isNaN(val)) {
		newCell.align = "right";
		val = addCommas(val.toFixed(2));
	} 
	if (lnk && lnk != "") {
		val = "<a href=" + lnk +" class=" + clr +">" + val + "</a>";
	}
	if (bld) {
		val = "<b>" + val + "</b>";
	}
	if (clr && clr != "") {
		newCell.style.color = clr;
	}
	newCell.innerHTML = val;
	if (spn > 1) {
		newCell.colSpan = spn;
	}
}

Open in new window


When I call the functions, I either errors in Firefox (IE execs the code just fine)

I have a table call out:
<table width=850 id=tabl name=tabl cellpadding=0 cellspacing=0 class=proc></table>

Open in new window


and the function calls:
<script>
ins_row(tabl);
add_data(tabl, 'text', 10, '', true, 'blue');
</script>

Open in new window


I have tried both leaving tabl unquoted, which gives me tabl undefined errors, and quoted, which give me tab.rows undefined.

Please help
0
Comment
Question by:srfreemaninc
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 33580643
0
 

Author Closing Comment

by:srfreemaninc
ID: 33581220
I added the getElementById line to reference the table, and it worked.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 33583752
yes, sorry I was too busy to dig out the actual solution and apply it.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I recently found myself in a Corporate Situation where the client had requested blocking access to any and all websites except his own Domain? Easy? I am sure this would be your answer but their requirement was, this has to be done without using…
This article discusses how to create an extensible mechanism for linked drop downs.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now