I have a list of checkboxes with ids, I can select the checkboxes and get all the ids by doing the following:
var order_id = []; //array to store order ids from the checkboxes
var x = 0; //count
checkboxes.each(function(){ //loop through the selected checkbox and store ids in array
if ($(this).hasClass('active')) {
order_id[x] = $(this).data('order-id');
x++; //increment x
});//end each
What I want to do is print out these ORDER ID numbers to my dymo label printer and in order to do that I need to use a XML file provided by Dymo. This file is located on the server, I can get the file by using $.get
$.get(url+"labels/dymo_19x51.xml", function(labelXml) {
//framework
var label = dymo.label.framework.openLabelXml(labelXml);
//Order ID is set here
label.setObjectText("TEXT", order_id[x]);
//Label is printed here
label.print(myDymoPrinter);
}, "TEXT");
The problem I'm having is, if I select 5 checkboxes, 5 labels will print but they will all be the same ie will print the last label selected 5 times. I can't get it to iterate through the order_id array within the $.get function. I've tried incrementing x at different points in my script, but I just can't make it happen.
ANY help is appreciated.
Many Thanks, Kahl