troubleshooting Question

add new rows with number of row in 1st colum

Avatar of easyrider439
easyrider439 asked on
JScriptAJAX
8 Comments1 Solution394 ViewsLast Modified:
I'm sure this question has been asked allot and I've tried to look through previous articles but i'm looking to add new rows to a table and in the first column (cell) I want it to display what number that row is, below is what i have and it just displays #3 in each row. I hope this makes sense. Thanks guys.


function addRow(divname)
{

var totalrows = document.getElementById('invoice').rows.length-1;


var product = '<?php echo $products; ?>';
var newdiv = document.createElement('<tr>');	
    newdiv.innerHTML = "<td><strong>" + (totalrows + 1) + "</strong></td><td><div class='field'><select name='product[]' id='product'><option selected='selected'></option>" + product + "</select></td>";
    document.getElementById(divname).appendChild(newdiv);
    
}

Open in new window

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros