getting parameter value from a table using javascript
Posted
by kawtousse
on Stack Overflow
See other posts from Stack Overflow
or by kawtousse
Published on 2010-05-24T09:01:44Z
Indexed on
2010/05/24
9:11 UTC
Read the original article
Hit count: 165
hi every one;
I want to get the parameter in my table(HTLML) table every time the user click edit button. The table contains in each row an edit button like following:
retour.append("<td>");
retour.append("<button id=edit name=edit type=button onClick= editarow()>");
retour.append("<img src=edit.gif />");
retour.append("</button>");
retour.append("</td>");
to get the value of each row where edit is clicked using javascript I do the following:
function editarow(){
var table = document.getElementById("sheet");
var buttons = table.getElementsByTagName("button");
for(var i=0; i<buttons.length; i++) {
if(buttons[i].name=="edit") {
buttons[i].onclick = function()
{
var buttonCell = this.parentNode;//cell
var editThisRow = buttonCell.parentNode;//td
var er=editThisRow.parentNode.attributes[1].value;
alert(er);
}
} }
}
but i didn't get the values expected. thanks for help
© Stack Overflow or respective owner