Link to home
Start Free TrialLog in
Avatar of limct
limct

asked on

How to get html table's particular column value?

Hi,

I am writing a javascript function to delete a row from a table filled with data. How to get one of the html table's column values so that I can delete the selected row?

Please give answer with code.
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
do you want to delete the rows in the html-table or do you want to do a delete of the data in the background on the server

if you just want to delete the html-table-row put this td in your table
--------------------------------------------------------------------------------
....
<td><a href="javascript:void null;" onclick="var e=this;while(e.tagName!='TR'){e=e.parentNode};if(e){e.parentNode.removeChild(e);}">[del]</a></td>
....
--------------------------------------------------------------------------------

you can also make a function:

put this to your head
-------------------------------------------------
<script type="text/javascript">
function delRow(e){
  //first find the tablerow
  while(e && e.tagName!='TR')
     e=e.parentNode;
  //if found then remove it form the table (e.parentNode='TBODY')
  if(e)
    e.parentNode.removeChild(e);
}
</script>
--------------------------------------------------------------------------------


then the tablecell can look like this:
--------------------------------------------------------------------------------
....
<td><img src="yourdelicon.gif" border=0 style="cursor:pointer;" onclick="delRow(this);"></td>
....
--------------------------------------------------------------------------------

hope this helps and you give me the points :)
First item in your member profile ragerino is LotusScript. Are you a PCLP?
Thanks for points and grading.

ragerino, wir sehen uns ;-)
Sorry Alex, I confused your member name with another guy.
hehe :)