Users can create any number of input fields and on save the values are saved as a JSON and sent to the server.
I can't add these user generated input field values into the JSON format and I get no output result of the JSON.
I'm doing it as below:
$(function () {
$(document).on('click', '.send', function (e) {
var dataGroup = [];
$('.form-group').each(function () {
var emailData = {};
$(this).find(':input[data-name]').each(function () {
emailData[$(this).emailData('name')] = this.value
});
dataGroup.push(emailData);
});
$('#result').val(JSON.stringify(dataGroup))
});
});
This is the JSFiddle. How can you add each input field into the JSON?