Solved

insertCell not working in Firefox

Posted on 2010-09-01
3
639 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
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.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

734 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