I am trying to create an array in javascript.
Here is my code:
var arr = {};
for (q = 0; q < ids.length; q++) {
var rowId = ids[q];
var rowData = jQuery("#<%= JQGrid2.ClientID %>").jqGrid('getRowData', rowId);
arr["section"] = rowData.inv_section;
arr["po"] = rowData.cust_po;
arr["description"] = rowData.description;
};
console.log(arr);
The result of the above code is:
{description: "Telephone Calls", po: "PO3547", section: "Telephony"}
However I would like to concatenate all the items in the loop, so I end up with an array, that looks like the below:
[{description: "Telephone Calls", po: "PO3547", section: "Telephony"},
{section: Telephony, po: "PO0067", description: "ISDN"},
{section: Managed Service, po: "PO0066", description: "Desktop Support"},
{section: Managed Service, po: "PO0066", description: "Desktop Support"}]