Dynamic JSON - JSFiddle - JSFiddle

Creating JSON

by litespeedtdf

HTML

<input id="testing" name="jonathan" />
<br>

<div style="height:100px;">
<div id="f" style="display:none"></div>
<div id="l" style="display:none"></div>
</div>


<div>
<button id="first">
  Show First Name
</button>
<button id="last">
  Show Last Name
</button>
</div>

JavaScript

$(function() {
//$('#f').hide();
//$('#l').hide();

  $('#first').on('click', function() {
    displayMessageDiv(true, 'Jonathan');
  
  });
    $('#last').on('click', function() {
    displayMessageDiv(false, 'MacKey');
  
  });
  
window.setTimeout(function() {
    //alert('Hello World!');
     $('#j').hide();
}, 5000);

 function displayMessageDiv(showFirstName, message) {
 								if (showFirstName === true) {
                		$('#l').text(message).hide();
                    $('#f').text(message).show();                    
                } else {
                		$('#f').text(message).hide()
                    $('#l').text(message).show();
                }
            window.setTimeout(function () {
                if (showFirstName === true) {                		
                    $('#f').fadeOut(400);                    
                } else {
                		$('#l').fadeOut(400);
                }
            }, 5000);

 }

  /*
  	//alert($('#testing').attr('name'));
    var colArray = ['id', 'Hour', 'Minute', 'BatchType'];
    var colValues = ['1', '2', '30', '1'];
    var resultsArray = [];  
    var jName = 'PrintTimes'; 
    var colId = 'id';
    var colIdValue = '1';  
  	var colHour = 'Hour';
    var colHourValue = '2';  
    var colMinute = 'Minute';
    var colMinuteValue = '30';
    var colBatchType = 'BatchType';
    var colGBatchTypeValue = '1';
    var nameAndValue = colHour + ':' + colHourValue;
            var colName = '';
          var tempValue = '';
          var tempString = [];
          var tempNV = '';
          var len = colArray.length -1;
          
           var colArray2 = [];
           alert(colArray2.length);
          
          
          for(var k = 0; k <= 2; k++){
            		for (var j = 0; j < colArray.length; j++) {               
                 colName = colArray[j];
                 if(k === 0)
                 	tempValue = parseInt(colValues[j]);
                  else
                  		tempValue...