!!! html head title= title link(rel='stylesheet', href='/stylesheets/style.css') script(src='http://code.jquery.com/jquery-1.6.1.min.js') script(src='/socket.io/socket.io.js') script(src='/form2js/form2js.js') script(src='/form2js/jquery.toObject.js') script(src='/form2js/json2.js') script //$(document).ready(function() { var socket = io.connect('http://localhost:3000'); socket.on('populate', function(json) { var out = ""; for (var n in json) { // Each top-level entry out += '
  • ' + n + '
  • '; }; console.log('out ' + out); $('#employees').html(out); }); $(function() { //Add more fields dynamically. $('.AddNeut').click(function() { var field = $(this).attr('data-field'); var area = $(this).attr('data-area'); var limit = $(this).attr('data-limit'); var jsontag = $(this).attr('data-jsontag'); var last_item = $('.' + area ).length; console.log('.' + area + ' li') console.log('LastItem - ',last_item, 'next_Item - ', (last_item + 1) ); // create the new element via clone(), and manipulate it's ID using newNum value var newElem = $('ol#' + field + ' li:first').clone().attr('style', 'display: block'); $(newElem).attr('class', area); $(newElem).children('input').attr('disabled',false); $(newElem).children('input').each(function(){ var newName = $(this).attr('name').replace('[]','[' +(last_item + 1) + ']') $(this).attr('name', newName); console.log('name ' + newName); }); $(newElem).appendTo('ol#' +field); }); $('#save').click(function() { var selector= "#myForm" //var formDataFirst = $(selector).toObject({mode: 'first'}); var formDataAll = $(selector).toObject({mode: 'all'}); socket.emit('data', formDataAll); console.log('All ', JSON.stringify(formDataAll, null, '\t')); // to prevent the page from changing return false; }); }); body!= body