So I have a page where people will be able to randomly generate some input fields, so I need to get the value of every single input and send it to my php page.
The tricky part is that I don't know how many inputs will there be in the end, and therefor I need some kind of a loop to pick all the values up. Here is what I have right now, everything seems to be ok and I do manage to get all the input fields. But for some reason values of every input field seems to be undefined, does anyone know why?
$(document).on('click', '#izmena', function(){
$(function() {
var collectionA = $('.crtezInput');
var datas = [];
$.each(collectionA, function(idx, obj) {
datas.push({ 'input': $(obj).find('input').val() });
});
$.each(datas, function(idx, obj) {
crtezNaziv += obj.input +",";
});
console.log(crtezNaziv);
});
<div id="izmena_crteza">
<div class="headlinea">Crtezi</div>
<div class="crtez-form">
<input type="text" style="width:80%; margin-bottom:10px;" class="form-control upis-style crtezInput" placeholder="Naziv" value="Glavni izgled">
<i title="Obrisi Arhitektu" style="margin-top: -18px;" class="fa fa-times fa-2x deleteArh"></i>
<input type="text" style="margin-top:-20px; width:80%; margin-bottom:10px;" class="form-control upis-style crtezInput" placeholder="Razmera" value="1:100">
<input type="text" style="width:80%; margin-bottom:10px;" class="form-control upis-style crtezInput" placeholder="Tehnika" value="Tus">
</div>
<div class="crtez-form">
<input type="text" style="width:80%; margin-bottom:10px;" class="form-control upis-style crtezInput" placeholder="Naziv" value="Izgled sa strane">
<i title="Obrisi Arhitektu" style="margin-top: -18px;" class="fa fa-times fa-2x deleteArh"></i>
<input type="text" style="margin-top:-20px; width:80%; margin-bottom:10px;" class="form-control upis-style crtezInput" placeholder="Razmera" value="1:100">
<input type="text" style="width:80%; margin-bottom:10px;" class="form-control upis-style crtezInput" placeholder="Tehnika" value="Tus">
</div>
<div class="crtez-form">
<input type="text" style="width:80%; margin-bottom:10px;" class="form-control upis-style crtezInput" placeholder="Naziv" value="Presek a-b">
<i title="Obrisi Arhitektu" style="margin-top: -18px;" class="fa fa-times fa-2x deleteArh"></i>
<input type="text" style="margin-top:-20px; width:80%; margin-bottom:10px;" class="form-control upis-style crtezInput" placeholder="Razmera" value="1:100">
<input type="text" style="width:80%; margin-bottom:10px;" class="form-control upis-style crtezInput" placeholder="Tehnika" value="Tus">
</div>
</div>