Hey guys i have a little issue with my script , im not managing to make the printing script to work for every row.
I know that i need to assign id for every row in the table but
The printing its working only for the first row in table not an expert on java so if someone could help me i will be greatfull.
(function()
{
// called when the document completly loaded
function onload()
{
var model_text = document.getElementById('model_text');
var defect_text = document.getElementById('defect_text');
var imei_text = document.getElementById('imei_text');
var batch_text = document.getElementById('batch_text');
var printButton = document.getElementById('printButton');
// prints the label
printButton.onclick = function()
{
try
{
// open label
';
var label = dymo.label.framework.openLabelXml(labelXml);
// set label text
label.setObjectText("model_text", model_text.value);
label.setObjectText("defect_text", defect_text.value);
label.setObjectText('imei_text', imei_text.value);
label.setObjectText('batch_text', batch_text.value);
// select printer to print on
// for simplicity sake just use the first LabelWriter printer
var printers = dymo.label.framework.getPrinters();
if (printers.length == 0)
throw "No DYMO printers are installed. Install DYMO printers.";
var printerName = "";
for (var i = 0; i < printers.length; ++i)
{
var printer = printers[i];
if (printer.printerType == "LabelWriterPrinter")
{
printerName = printer.name;
break;
}
}
if (printerName == "")
throw "No LabelWriter printers found. Install LabelWriter printer";
// finally print the label
label.print(printerName);
}
catch(e)
{
alert(e.message || e);
}
}
};
// register onload event
if (window.addEventListener)
window.addEventListener("load", onload, false);
else if (window.attachEvent)
window.attachEvent("onload", onload);
else
window.onload = onload;
} ());
<script src = "dymo.connect.framework.js" type="text/javascript" charset="UTF-8"> </script>
<script src = "PrintLabels.js" type="text/javascript" charset="UTF-8"> </script>
<title>Phone list</title>
</head>
<body>
<div class="container">
<span id="success_message"></span>
<div class="card">
<div class="card-header">
<div class="row">
<div class="col col-md-6"> list</div>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="empTable" class="table table-striped" style="width:100%">
<thead>
<tr>
<th>Imei</th>
<th>Date</th>
<th>Engineer</th>
<th>Model</th>
<th>Labour</th>
<th>Price</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($results as $rs) { ;?>
<tr>
<td><input type="" id="id" name="id" value="<?= $rs['id'] ?>"></td>
<td><input type="hidden" id="imei_text" name="imei_text" value="<?= $rs['imei'] ?>"><?= $rs['imei'] ?></td>
<td><?= $rs['date'] ?></td>
<td ><input type="hidden" id="defect_text" name="defect_text" value="<?= $rs['engineer'] ?>"><?= $rs['engineer'] ?></td>
<td><input type="hidden" id="model_text" name="model_text" value="<?= $rs['model'] ?>"><?= $rs['model'] ?></td>
<td><?= $rs['job1_n'] ?></td>
<td><?= $rs['total'] ?></td>
<td><input type="hidden" id="batch_text" name="batch_text" value="<?= $rs['status'] ?>"><?= $rs['status'] ?></td>
<td>
<button type="button" class="btn btn-outline-success" onclick="pass_data('<?=$rs["id"];?>')" >Pass</button>
<button type="button" class="btn btn-outline-danger" onclick="fail_data('<?=$rs["id"];?>')">Fail</button>
<input type="submit" id="printButton" name="printButton" value="Print" />
</td>
</tr>
<?php $result++;
}
echo "Count = $result";
?>
</tbody>
<tfoot>
<tr>
<th>Imei</th>
<th>Date</th>
<th>Engineer</th>
<th>Model</th>
<th>Labour</th>
<th>Price</th>
<th>Status</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</body>
</html>
The first thing you are going to want to do is make sure you are using the latest version of the dymo connect framework.
Then you need to generate a set of labels using an instance of
LabelSetBulder
.Instead of calling the
print
method on the label object itself, you would then call theprintLabel
method passing in the generated label set data.