Results 1 to 2 of 2

Thread: Populate data from tables

  1. #1
    Join Date
    Oct 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Populate data from tables

    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,069
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    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:

    Code:
    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •