Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中使用AJAX创建条形码阅读器_Php_Jquery_Html_Ajax_Barcode - Fatal编程技术网

在PHP中使用AJAX创建条形码阅读器

在PHP中使用AJAX创建条形码阅读器,php,jquery,html,ajax,barcode,Php,Jquery,Html,Ajax,Barcode,我正在尝试使用php构建一个应用程序。在stock_out.php中,我想创建一个包含两个条形码的表单。我有8个字段。生效日期、零件号、说明、NPK、NAMA、QTYOUT、原因。我想在零件号和NPK中使用条形码阅读器。 我有一些问题: 1.当我按enter键时,它将响应按钮submit。 2.实际上,当我在Partnumber中按enter键时,我希望在description1和description2中显示详细信息数据。以及在NPK中,我希望在nama中显示详细信息数据 3.在表单的末尾,我

我正在尝试使用php构建一个应用程序。在stock_out.php中,我想创建一个包含两个条形码的表单。我有8个字段。生效日期、零件号、说明、NPK、NAMA、QTYOUT、原因。我想在零件号和NPK中使用条形码阅读器。 我有一些问题: 1.当我按enter键时,它将响应按钮submit。 2.实际上,当我在Partnumber中按enter键时,我希望在description1和description2中显示详细信息数据。以及在NPK中,我希望在nama中显示详细信息数据 3.在表单的末尾,我仍然希望将此表单提交到数据库中。 我是AJAX的新手,所以我仍然不知道如何在PHP中实现AJAX。这是我的代码,谢谢你的帮助

<html><body>
<div id="outerContainer">
    <?php include("headerFile.html"); ?>
    <?php include("navigationFile.html"); ?>
    <div id="bodyContainer">
        <div id="pageBodyTitle"> Stock Out </div> <br>
        <form id="formSearch" name="formSearch" method="post" action="proses_out.php" onSubmit="return cek_data();">
        <table id="messageTable">
            <tr>
                <td class="heading"> Effective Date </td>
                <td>
                    <input class="inputField" name="tgl" type="text" readonly  value="<?php echo $_POST['tgl']?>" tabindex="1"/>
                    <script language='JavaScript'>new tcal ({'formname': 'formSearch','controlname': 'tgl'});</script>
                </td> 
            </tr>
            <tr>
                <td class="heading"> Part Number </td>
                <td><input type='text' name='txtItem' id='txtItem' size="20" class="inputField" value='<?php echo $item;?>' tabindex="2" />
                <img src='search.ico' onClick='open_win_item()'> </td>
            </tr>
            <tr>
                <td class="heading">Description1</td>
                <td><input type='text' name='txtDesc1' id='txtDesc1' size="50" value='<?php echo $desc1;?>'  readonly /></td>
            </tr>
            <tr>
                <td class="heading">Description2</td>
                <td><input type='text' name='txtDesc2' id='txtDesc2' size="50" value='<?php echo $desc2;?>'  readonly /></td>
            </tr>
            <tr>
                <td class="heading"> NPK </td>
                <td><input type='text' name='txtNpk' id='txtNpk' size="20" maxlength="5" class="inputField" value='<?php echo $tr_no;?>' tabindex="3" />
                    <img src='search.ico' onClick='open_win_npk()'></td>
            </tr>
            <tr>
                <td class="heading">Nama</td>
                <td><input type='text' name='txtName' id='txtName' size="30" value='<?php echo $nama;?>' readonly /></td>
            </tr>
            <tr>
                <td class="heading"> Qty Out </td>
                <td><input type='text' name='txtQty' id='txtQty' size="5" class="inputField" tabindex="4"/></td>
            </tr>
            <tr>
                <td class="heading"> Reason </td>                   
                <td><select class="inputField" name="choose" id="choose" value="" tabindex="5">
                <?php
                include "/class/connect_SQL.class.php";
                $sql = "select reason_code from Inv_reason_master";
                $query = mssql_query($sql);
                    while ($row = mssql_fetch_array($query)) 
                    {
                        $coba = $row['reason_code'];
                    ?>
                        <option value="<?php echo $coba; ?>"><?php echo $coba;?></option>
                    <?php
                    }
                    ?>
                </select></td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="submit" name="Submit" value="Save" class="formButton2" tabindex="6"/>
                    <input type="reset" name="reset" value="Cancel" class="formButton2" tabindex="7"/>
                </td>
            </tr>
        </table>

        </form>
    </div>
    <?php
        if(isset($_GET["message"]) and  $_GET["message"]='save')
        {
            echo "<script language=\"javascript\"> alert('Data Tersimpan!') </script>";
        }
    ?>
    <?php include("footerFile.html"); ?>
</div>

您必须阻止Enter键的响应。如果您在项目中使用jquery,可以使用以下代码阻止它:

$(function() {

    $("form").bind("keypress", function(e) {
            if (e.keyCode == 13) return false;
      });

});
要将Enter键绑定到零件号字段,您可以尝试以下操作:

$('#txtItem').keypress(function(e) {
    if (e.keyCode == 13) {
        alert('Enter is pressed in part number');
    }
});

请参阅此链接以了解php中的ajax可能的重复项它不是重复项,这只是提交表单。。。我可以将所有字段提交到数据库中,但无法在条形码阅读器中实现。