Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I can't seem to extract the value of the input text below in my html table.

var cntr = 0;
                var TableData;
                //+ $(tr).find("td:input." + dtp).val();

                $('#dta tr').each(function (row, tr)
                {
                    var dtp = "datepicker_" + cntr;
                    if (cntr > 0)
                    {
                        TableData =
                            $(tr).find('td:eq(0)').text() + ', '
                            + $(tr).find('td:eq(1)').text() + ', '
                            + $(tr).find('td:eq(2)').text() + ', '
                            /*+ $(tr).find('td:eq(3) input[type="text"]').val();*/
                            + $(tr).parents('td').siblings().find('input');
                            
                        alert(TableData);
                    }
                    cntr++;
                    if (cntr > 4) return;
                });


What I have tried:

jquery:

var cntr = 0;
                var TableData;
                //+ $(tr).find("td:input." + dtp).val();

                $('#dta tr').each(function (row, tr)
                {
                    var dtp = "datepicker_" + cntr;
                    if (cntr > 0)
                    {
                        TableData =
                            $(tr).find('td:eq(0)').text() + ', '
                            + $(tr).find('td:eq(1)').text() + ', '
                            + $(tr).find('td:eq(2)').text() + ', '
                            /*+ $(tr).find('td:eq(3) input[type="text"]').val();*/
                            + $(tr).parents('td').siblings().find('input');
                            
                        alert(TableData);
                    }
                    cntr++;
                    if (cntr > 4) return;
                });
Posted
Comments
Richard Deeming 11-Jun-21 4:24am    
We can't see your HTML markup. But the $(tr).parents('td') looks suspicious to me. Are you sure your table is nested inside another table?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900