你们让我起个名啊 2017-10-26 05:48 采纳率: 42.3%
浏览 1008
已结题

json 文本框如何联动填写信息?

后台已经封装好了json数据,请问如何做到用户填写deviceid后,自动填写与deviceid关联的deviceid_name 和brand?

 <tr id="tOutWarehouseSlaveList{{idx}}">

                            <td>
                                <input path ="tInventoryTable"  id="tOutWarehouseSlaveList{{idx}}_deviceid" name="tOutWarehouseSlaveList[{{idx}}].deviceid" type="text" value="{{row.deviceid}}" maxlength="255" class="input-small " onblur = "tInventoryTableInfo()"/>
                            </td>
                            <td>
                                <input id="tOutWarehouseSlaveList{{idx}}_devicename" name="tOutWarehouseSlaveList[{{idx}}].devicename" type="text" value="{{row.devicename}}" maxlength="255" class="input-small "/>
                            </td>
                            <td>
                                <input id="tOutWarehouseSlaveList{{idx}}_brand" name="tOutWarehouseSlaveList[{{idx}}].brand" type="text" value="{{row.brand}}" maxlength="255" class="input-small "/>
                            </td>
                            </tr>
  • 写回答

1条回答 默认 最新

  • Go 旅城通票 2017-10-26 06:11
    关注

    tInventoryTableInfo用ajax发送输入的信息到服务器,服务器通过参数读取信息返回,ajax获取返回值后设置控件的值即可

     <script type="text/javascript" src="https://cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script>
    <tr id="tOutWarehouseSlaveList{{idx}}">
    
        <td>
            <input path="tInventoryTable" id="tOutWarehouseSlaveList{{idx}}_deviceid" name="tOutWarehouseSlaveList[{{idx}}].deviceid" type="text" value="{{row.deviceid}}" maxlength="255" class="input-small " onblur="tInventoryTableInfo(this)" />
        </td>
        <td>
            <input id="tOutWarehouseSlaveList{{idx}}_devicename" name="tOutWarehouseSlaveList[{{idx}}].devicename" type="text" value="{{row.devicename}}" maxlength="255" class="input-small " />
        </td>
        <td>
            <input id="tOutWarehouseSlaveList{{idx}}_brand" name="tOutWarehouseSlaveList[{{idx}}].brand" type="text" value="{{row.brand}}" maxlength="255" class="input-small " />
        </td>
    </tr>
    <script>
        function tInventoryTableInfo(el) {
            if (el.value != '')
                $.get('xxxx.url', { id: id }, function (d) {//xxxx.url获取id参数查询数据库后返回 用|分隔的内容就行了。第一个为devicename,第二个为brand
                    var arr = d.split('|'),ipt=$(el).closest('tr').find('input')
                    ipt[1].value = arr[0]; ipt[2].value = arr[1];
                });
        }
    </script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题