A straight-forward jQuery $.each loop over a table row. I am not so good with objects and am running into difficulty with the .push() method.
I should be getting:
[{"buyerPoINPUT":"1234567"},{"jobINPUT":"Replace grommit"},{"shipMethodINPUT":"etc"}]
Instead, I am getting:
[{"t1":"1234567"},{"t1":"Replace grommit"},{"t1":"etc"}]
Why am I getting the t1 variable name, repeated, instead of the t1 var contents (id attribute)?
HTML:
<div id="summaryTableDIV" class="b1">
<table id="summaryTable">
<thead>
<th id="buyerPoTH">PO NO.</th><th id="jobTH">JOB</th><th id="shipMethodTH">SHIPPING<br>METHOD</th><th id="shipTermsTH">SHIPPING<br>TERMS</th><th id="payTermsTH">PAYMENT<br>TERMS</th><th id="blankTH"></th>
</thead>
<tbody>
<td id="buyerPoTD" ><input type="text" id="buyerPoINPUT" value="1234567" /></td>
<td id="jobTD" ><input type="text" id="jobINPUT" value="Replace grommit" /></td>
<td id="shipMethodTD"><input type="text" id="shipMethodINPUT" value="Loomis or DHL" /></td>
<td id="shipTermsTD" ><input type="text" id="shipTermsINPUT" value="FOB Washington" /></td>
<td id="payTermsTD" ><input type="text" id="shipMethodINPUT" value="see below" /></td>
<td id="blankTD" ><input type="text" id="blankINPUT" value="Okay to proceed" /></td>
</tbody>
</table>
</div><!-- #summaryTableDIV -->
js/jQ:
var objSumTbl = new Array();
$("#summaryTable > tbody > tr > td > input").each(function(){
var thisTD = $(this);
var t1 = thisTD.attr('id');
var t2 = thisTD.val();
objSumTbl.push({
t1 : t2
});
});
alert( JSON.stringify(objSumTbl) );
objSumTbl.push ({ $(this).attr('id') : t2})directly