[英]I have a code that show the barcode image but it will show only the image once
I am working to show the bar codes generated and stored in date base. 我正在努力显示以日期为基础生成和存储的条形码。 Right now i am able to get the bar code number from data base and show the image in HTML using code39.js. 现在,我能够从数据库中获取条形码编号,并使用code39.js以HTML格式显示图像。 My code is billow it will show the image once only i want to show all the image and then download the label for products. 我的代码是滚滚的,它将仅在我要显示所有图像后才显示图像,然后下载产品标签。
<div class="panel panel-info ">
<div class="panel panel-heading">
Bar Codes
</div>
<table class="table table-striped">
<tr>
<th>Product Name</th>
<th>Quantity</th>
</tr>
@foreach (var items in Model.BarCodeItems)
{
<tr>
<td>
@for (int i = 0; i <= @items.Quantity;i++ )
{
<div id="externalbox" style="width:4in">
<div id="inputdata">@items.BarCode</div>
</div>
<br />
}
</td>
<td>
@items.Name
@items.Quantity
</td>
</tr>
}
</table></div>
<script type="text/javascript"> function get_object(id) { var object = null; if (document.layers) { object = document.layers[id]; } else if (document.all) { object = document.all[id]; } else if (document.getElementById) { object = document.getElementById(id); } return object; } get_object("inputdata").innerHTML=DrawCode39Barcode(get_object("inputdata").innerHTML,8); </script>
You are using Ids, and it must be unique. 您正在使用ID,并且它必须是唯一的。 Try to use class, like this: 尝试使用类,如下所示:
<div class="externalbox" style="width:4in">
<div class="inputdata">@items.BarCode</div>
</div>
And in your script: 在您的脚本中:
$('.inputdata).each(function() {
var code = $(this).html();
$(this).html(DrawCode39Barcode(code,8));
});
If you don't want to use jQuery: 如果您不想使用jQuery:
var x = document.getElementsByClassName("inputdata");
for (var i = 0; i < x.length; i++) {
var code = x[i].innerHtml;
x[i].innerHtml = DrawCode39Barcode(code,8);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.