$('#download2').click(function(event){ $("#formtable").each(function (i) { console.log($('input[type="text"]').val()); console.log($('label[for="lastName"]').text()); }); }); 

It is impossible to get all the value of input, for some reason, one value is output and the one that did not go to the formtable. And for example, the label I have all the values ​​are obtained normally. What have I done wrong?

    1 answer 1

    1. Why loop each by id? id should be one per page.
    2. console.log($('input[type="text"]').val()); - here all the inputs are selected, not just one, so the value is displayed one (either the first or the last, I don’t remember exactly)
    3. But the label is apparently one on the page, so everything is OK

    In general, you need to more accurately describe the problem, so nothing is particularly clear.

    • I need to go through the entire form, and write all the data in json, then to form an xml document in php. For example, I should get json {label1: input1, label2: input 2} - Kureid
    • var mass = $ (": input") .serializeArray (); I did so)) - Kureid