duanmianhong4893 2013-02-14 18:00
浏览 46

参考另一个文本输入的值自动完成文本输入

I have two fields, one of which has the jQuery autoComplete plugin.

<input type='text' name='primary_diagnosis' id='icd1-diagnosis'/>
<input type='text' name='ICD_No1' id='icd1-num' />

$(document).ready(function(){
    $("#icd1-diagnosis").autocomplete("autocomplete-icd.php", 
    {
        selectFirst: true
    });
});

Is there a way to automatically fill up the second text input once a value has been selected for the first? For example, selecting "Dengue fever [classical dengue]" for the first text input, then query the database for certain value to yeild "A90" as the value for the second text input.

Here's autocomplete-icd.php

<?php
    include('config.php');
    $q=$_GET['q'];
    $my_data=$q;

    $sql=mysql_query("SELECT col9 FROM tb_data_icd WHERE col9 LIKE '%$my_data%' ORDER BY col9",$con);
    if($sql)
    {
        while($row=mysql_fetch_array($sql))
        {
            $col9=$row['col9'];
            echo "$col9"."
";
        }
    } 
?>
  • 写回答

1条回答 默认 最新

  • douguiyan9164 2013-02-14 18:49
    关注

    You should be able to use the change event to fire off some javascript to update the second input's value. Something like this:

    $("#icd1-diagnosis").change(function(){
        //retrieve your value
        var val = 'sample';
        $('#icd1-num').val(val);
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程