PDA

View Full Version : Populate data from tables



suman
10-30-2006, 04:16 AM
I have a table with x rows, 2 coloumns(Number, Name) with data.when i right cklick on the row on Number, i have my own contect menu with options DeleteRow.when i click on deleteRow, i want to pick the Number on which i right clicked,Pass the value to an array.Plz give me code

jscheuer1
10-31-2006, 05:51 PM
It depends upon how you are getting the row. If the context menu appears as the result of an event of the row, the row will be 'this' unless you were attaching the event in IE (object.attachEvent(sEvent, fpNotify)), in which case it would be 'event.srcElement'. However you get it, once you have the row as an element - say, it is now contained in the variable r - it's first cell's innerHTML will contain the data you seek:


r.cells[0].innerHTML

If all that is there is the number you want and if it can be passed along as a string, you are in business. If you want it to be a number instead of a string, there are various things you can do, one method:


parseInt(r.cells[0].innerHTML, 10)

Or, if you need to tease the numerical value out of other content also contained in that cell's innerHTML, that can be done as well but, it would depend upon the typical return value of that innerHTML.