doubianxian6557 2019-05-29 14:16
浏览 58

如何使用<input>更改我的<select>以使用条形码扫描仪

I'm about to change a script, and right know the script are using an <select> with one options and echo to be used to show the products.

Now I'll like to change the <select> to a <input> so I can scan a barcode, and the information from the product should be added to the DB as it is right now, but I'm lost, I have used several hours to figuere out how to change it, I thought the solution was to use a hidded but then I can't add the first knowen product to my list.

Could someone please help me? :)

I've tried to use more boxes to get the products, but that was a big mess.

 <div class="col-md-6">
  <div class="form-group">
    <label for="date">Product Name</label>
    <select class="form-control select2" name="prod_name" tabindex="1" autofocus required>
      <?php
        $branch=$_SESSION['branch'];
        $cid=$_REQUEST['cid'];

        include('../dist/includes/dbcon.php');

        $query2=mysqli_query($con,"select * from product where branch_id='$branch' order by prod_name")or die(mysqli_error());

          while($row=mysqli_fetch_array($query2)){
            ?>
            <option value="<?php echo $row['prod_id'];?>"><?php echo $row['prod_name']." Available(".$row['prod_qty'].")";?></option>
          <?php }?>
    </select>

      <input type="hidden" class="form-control" name="cid" value="<?php echo $cid;?>" required>   
    </div><!-- /.form group -->
  </div>
  <div class=" col-md-2">
    <div class="form-group">
      <label for="date">Quantity</label>
      <div class="input-group">
        <input type="number" class="form-control pull-right" id="date" name="qty" placeholder="Quantity" tabindex="2" value="1"  required>
      </div><!-- /.input group -->
    </div><!-- /.form group -->
  </div>
  <div class="col-md-2">
    <div class="form-group">
      <label for="date"></label>
      <div class="input-group">
        <button class="btn btn-lg btn-primary" type="submit" tabindex="3" name="addtocart">+</button>
      </div>
    </div>

The code should be changed to use a <input> or something simular, so I can use a barcode scanner to add my items to a list.

  • 写回答

1条回答 默认 最新

  • dongmei9961 2019-05-30 16:08
    关注

    What I did to get my result was:

    I changed the prod_id to be the barcode, and on scan the form is submitted to a temp_db, to show every items, and then added a "finish db" called inStock, and everything was as it should be! :)

    /Kenneth

    评论

报告相同问题?

悬赏问题

  • ¥15 vue3加ant-design-vue无法渲染出页面
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序