How can I get all data in this case?
How can I get all data in this case?
Hokwang
Posts: 8Questions: 4Answers: 0
Hello.
I make a table like http://live.datatables.net/bazilay/1.
There are <select> in table.
In this case how can I get all data in table?
I want to send table data using ajax to another page.
I am using latest version of datatable.
I am thinking about..
$("#table").row().each(function() {
data[] = [$(this).children("td:first-child").val(), $(this).children("td:nth-child(2)").val(), $(this).children("td:last-child").text()];
});
Thank you in advance.
This question has accepted answers - jump to:
This discussion has been closed.
Answers
There are a number of ways to do it, but this one is fairly succinct:
i.e. get the
tr
nodes for all rows usingrows().nodes()
and then use jQuery to get theselect
elements.Allan
Thank you. allan.
But, please show more detail.
How can I send all data to another page?
There are 2 (or more) rows and 2 (or more) collunms..
count of rows will be changed.
I successed getting one select val using
but I need all data..
What do you mean a different page? A pop up window, a reloaded page, or an Ajax call like you have above?
For each of those, those are general javascript questions and you might be best to ask on SO or similar. The above code will get the select elements from the table, and you can then use jQuery's map method, or similar, to build an array of values.
Allan