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 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch