如何在PHP

时间:2015-10-02 15:48:28

标签: php jquery mysql barcode

我正在使用PHP,jquery,mysql开发一个小型库存管理器Web应用程序....我想在应用程序中添加条形码功能

请在几次搜索后,我在这里使用此代码;大拇指到海报。 但我被困在这里:

我想通过从同一页面上的数据表中选择带有productcode / productid的项目/项目来生成多个条形码图像到可打印区域,并使用添加按钮将它一个接一个地添加到可打印区域? / p>

   <style> 
   @font-face { 
  font-family: barcode; 
  src: url(free3of9.ttf); 
   }
    </style>

    <body> ABC 
    <div style='font-family:barcode;font-size:32px;'> 
   123456789    </div> DEF</body>

      </html>

enter image description here

1 个答案:

答案 0 :(得分:2)

首先,要使用此字体,您需要将其与您正在使用的页面一起上传到Web服务器。这个例子可以用JQuery描述,但条形码不会是样式,因为jsfiddle没有托管Font。

http://jsfiddle.net/Twisty/72ewdoj4/

<强> HTML

<ul class="form">
    <li>
        <label>Top Text:</label>
        <input type="text" id="top" />
    </li>
    <li>
        <label>Barcode:</label>
        <input type="text" id="bar" />
    </li>
    <li>
        <label>Bottom Text:</label>
        <input type="text" id="bottom" />
    </li>
    <li>
        <button id="add">Add</button>
</ul>
<hr />
<table id="results">
    <tr>
        <td> <span class="label">ABC</span>
 <span class="bar label">123456789</span>
 <span class="label">DEF</span>

        </td>
    </tr>
</table>

<强> CSS

@font-face {
    font-family: barcode;
    src: url(3OF9_NEW.TTF);
}
.label {
    display: block;
}
.bar {
    font-family:barcode;
    font-size:32px;
}
#results {
    width: 100%;
}
#results td {
    padding: 10px 0;
    text-align: center;
}
ul.form {
    margin: 0;
    padding: 0;
}
ul.form li {
    margin: 0;
    list-style: none;
}
ul.form li label {
    display: inline-block;
    width: 120px;
}

<强> JQuery的

$(document).ready(function () {
    $("#add").click(function () {
        var newLabel = "<tr><td>"
        newLabel += "<span class='label'>" + $("#top").val() + "</span>";
        newLabel += "<span class='bar label'>" + $("#bar").val() + "</span>";
        newLabel += "<span class='label'>" + $("#bottom").val() + "</span>";
        newLabel += "</td></td>";
        $("#results").append(newLabel);
    });
});