Jump to content

Error in Insterting row


harshpandya
 Share

Recommended Posts

Hi all , I am trying to add new row and pass diffrent variables inside the table. works fine. But when i pass different ids, it does not work and says invalid argument errorI dont understand why it will look for table id 1st time and when i pass different id in same function - it does not able to find another table id. INSHORT I AM TRYING TO ADD ROWs IN 1st TABLE AND GO TO 2nd TABLE AND ADD another ROWs -- PROBLEM HAPPENS WHEN I GO FROM 1st TABLE ID to 2nd TABLE IDError comes like - invalid argument......... function insRow(id, Tname, Result, Details){ num++;alert(id); var row = document.getElementById(id).insertRow(num); var number1 = row.insertCell(0); var Tname1 = row.insertCell(1); var Result1 = row.insertCell(2); var Details1 = row.insertCell(3); number1.innerHTML="<span style='color:#000000'><strong>" + num + "</strong></span>"; Tname1.innerHTML="<span style='color:#000000'><strong>" + Tname + "</strong></span>"; if(Result == 'Pass'){ Result1.innerHTML="<span style='color:green'><strong>" + Result + "</strong></span>"; }else{ Result1.innerHTML="<span style='color:red'><strong>" + Result + "</strong></span>"; } Details1.innerHTML="<span style='color:#000000'><strong>" + Details + "</strong></span>"; }thanks,

Link to comment
Share on other sites

I notice you've got num declared as a global variable (for persistence, which in general is okay). But would the same value be consistent from one table to the next? I'm imagining you incrementing the number of rows in table A to 4, and then trying to add a row to table B, which would bring the value of num up to 5, but if table B only has 2 rows, then your index is invalid. I get a different error in Firefox, but maybe your browser reports this as "invalid argument error".

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...