Solved

insertCell not working in Firefox

Posted on 2010-09-01
3
626 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.

856 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