Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72358

How do I access the value of a td (x3) of the same tr (x1), if I click on the tr (x1 of td (x2))?

$
0
0

How do I access the value of a td (x3) of the same tr (x1), if I click on the tr (x1 of td (x2))?

$(document).ready(function () {
    $.ajax({
        url: '/api/Usuario/GetPermisosRolPorUsuario',
        method: 'GET',
        dataType:'JSON',
        data: { NitEmpresa,NombreUsuario },
        headers: {
            'Authorization': 'Bearer '
                + sessionStorage.getItem("accessToken")
        },
        success: function (data) {
            debugger
            $('#tblBody').empty();
            $.each(data, function (index, value) {
                var row =
                    $('<tr>'
                        +'<td id="IdUsuario">'+ value.IdUsuario + '</td>'
                        + '<td id="RolId">'   + value.RolId     + '</td>'
                        + '<td id="Estado">' + value.Estado + '</td>'
                        + '<td>' + value.Rol + '</td>'
                        + '<td>' + value.DescripcionRol + '</td>'
                        + '<td>' + value.NombreUsuario + '</td>'
                        + '<td>' + value.FullName + '</td>'
                        + '<td>' + value.licenciaEmpresa + '</td>'
                        + '<td>' + value.RazonSocial + '</td>'
                        + '<td>' + value.NitEmpresa + '</td>'
                        + '<td>' + value.Correo + '</td>'
                        + '<td>' + value.Celular + '</td>'
                        + '<td>' + formatDate(value.licenciaFechaExpire) + '</td>'
                    );
                $('#tblData').append(row);
            });

            $('#tblBody tr').on('click', '#Estado', function ()
            {
                var celda = $(this).text();

                var Estado = 0;

                //This is the traditional way without '#Estado', but I need to put several clicks, in different cells (td = 1, td = 2 and td 3) in all cases capture the same data from a tr, from different td
                var IdUsuario = $(this).find('td:first').html();

                //This is the traditional way without '#Estado', but I need to put several clicks, in different cells (td = 1, td = 2 and td 3) in all cases capture the same data from a tr, from different td
                var IdUsuario = $(this).find('td:first').html();

                //This is the traditional way without '#Estado', but I need to put several clicks, in different cells (td = 1, td = 2 and td 3) in all cases capture the same data from a tr, from different td
                var Estado1 = $(this).find('td:nth-child(3)').val();

                alert(celda +'-'+IdUsuario+'-'+Estado1 ); //test returns is null +IdUsuario+'-'+Estado1 (celda=ok)
            });
        },
        error: function (jQXHR) {
            toastr.error('Sistemas Infinitos Informa: '+jQXHR.responseText);
        }
    });
});

Viewing all articles
Browse latest Browse all 72358

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>