Solved

insertCell not working in Firefox

Posted on 2010-09-01
3
631 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

680 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