Dyno打印机聆听每个行活动
大家好,我的脚本有一个小问题,我没有设法使打印脚本适用于每一行。
我知道我需要为表中的每一行分配
ID 不是Java的专家,因此,如果有人可以帮助我,我会很大。
(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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您要做的第一件事是确保您使用的是最新版本的 dymo连接框架。
然后,您需要使用
LabelSetBulder
。您无需调用标签对象本身的
print
方法,而是调用printLabel
方法传入生成的标签集数据。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.