0
Hello
I am trying to recover the elements of a table and pass to a jquery array that will be used in ajax
I create the td dynamically:
var newRow = $("<tr>");
var cols = "";
cols += '<td class="tdProductId" id='+ $("#product option").attr("id") +'>'+ $("#product option").text() +'</td>';
cols += '<td class="tdProductAmount">'+ $("input[name=amount]").val() +'</td>';
cols += '<td class="tdProductPrice">'+ $("input[name=price]").val() +'</td>';
cols += '<td class="tdProductTotal">'+ $("input[name=price]").val() * $("input[name=amount]").val() +'</td>';
cols += '<td>';
cols += '<a href="#" class="removeProduct">Remover</a>';
cols += '</td>';
newRow.append(cols);
$("#input_stock_product").append(newRow);
The problem is to retrieve the attr from one td and the text from the other and put in an array What I tried to do, however, it n creates other indexes in the array, and ends up joining the values all together:
var productsData = {
id_product: $(".tdProductId").attr("id"),
amount: $(".tdProductAmount").text(),
price: $(".tdProductPrice").text(),
total: $(".tdProductTotal").text()
};
This way it returns me an object, ex:
Object {id_product: "137", amount: "12", price: "11", total: "132"}
have any idea how I would insert this array into a table with codeIgniter with ajax?
– zyzzete
Yes, but the answer is extensive. Can you ask a new question? So we can help more users who have the same question
– LF Ziron
http://answall.com/questions/123911/inserir-um-array-com-codeigniter-e-ajax
– zyzzete