const num_steps = 1; _.forEach(_.range(num_steps), function(value) { $('#step-' + (value+1) + ' form').submit(function(event) { $('#step-' + (value+2) ).collapse('show'); $('#step-' + (value+1) + '-heading .step-number').addClass('done'); event.preventDefault(); }); }); function gen() { var model = {}; _.forEach(_.range(num_steps), function(value) { _.each($('#step-' + (value + 1) + ' form').serializeArray(), function(value) { model[value.name] = value.value; }); }); var docDefinition = { content: [ { text: 'Mitgliedsantrag FabLab Neustadt Aisch/Bad Winsheim', fontSize: 20, margin: [0,0,0,20] }, { text: [ 'Name: ', { text: model.givenname + ' ' + model.surname, bold: true }, ] }, { text: [ 'Adresse: ', { text: model.address, bold: true }, ] }, { text: [ 'PLZ + Ort: ', { text: model.zip + ' ' + model.place, bold: true }, ] } ], pageSize: 'A4', pageMargins: [ 62.3622, 60, 62.3622, 60 ] }; pdfMake.createPdf(docDefinition).download('Mitgliedsantrag FabLab NEA.pdf'); }