onClick get row values from Html table

Sangwan Pankaj 1 10:02
How can You get table cell values and cells text boxes values?That means getting childNodes values using java script.This is easy using core javascripts.

Returns a nice array of your data, then you can display it how you want.

function updateRowData(id) {
    if(confirm("Are you sure you want to update this row?")) {
    //    alert(id);
       
        $("tr#table-row-"+id).click(function() {

//var tableData = $("tr#table-row-"+id).children("td").map(function() { // you can use this also but you need to comment upper line ( $("tr#table-row-"+id).click(function() { ) and uncomment this line   
  var tableRow = $(this).children("td").map(function() {
        return $(this).text();
    }).get();

    alert("Your data is: " + $.trim(
tableRow[0]) + " , " + $.trim(tableRow[1]) + " , " + $.trim(tableRow[2]));
});

    }
}
Copyright by GhostPHP. Powered by Blogger.

Search

Recent Post

Popular Posts

Follow us