First I would suggest you name your collections either with a classname or name the variable. The following code assumes you named the variable of the collection. This will only copy the fields if they are the basic field types such as Single-Line, Multi-Line, Radio Button, Checkbox, and Drop-Down. This could easily be expanded for Address, Number, Email, Date, Currency, and Signature field types, I just ran out of time (and interest). You will need to add this script to your "CSS and Javascript" section of your form.
$(document).ready(function() {
function copyFields() {
var _this=$('li[attr=mycollectionname] div.cf-collection div.form-q:last'), _prev = _this.prev().find('li').each(function() { switch ($(this).attr('attrtype')) {
case 'text':
_this.find('#'+this.id+' input.singleline').val($(this).find('input.singleline').val());
break;
case 'radio':
_this.find('#'+this.id+' input[type=radio][value="'+$(this).find('input[type=radio]:checked').val()+'"]').prop('checked',true);
break;
case 'longtext':
_this.find('[id="'+this.id+'"] textarea').val($(this).find('textarea').val());
break;
case 'checkbox':
var _t = this;
$(this).find('input[type=checkbox]:checked').each(function(i,e) {
_this.find('[id="'+_t.id+'"] input[type=checkbox][value="'+e.value+'"]').prop('checked',true);
});
break;
case 'select':
_this.find('#'+this.id+' select').val($(this).find('select').val());
break;
}
});
}
$(document).on('click','a.cf-collection-append',copyFields);
});
As for saving the data to a database. Is this an internally developed database? MSSQL, Sqlite, MySql, PostgreSql? Are you wanting to post the values using a webservice? Either way you decide to go, you will need to package the data in a JSON object, serialize it, and send it to a webservice for processing. Let me know if you need more help on this.