doufuhao8085 2014-04-10 05:28
浏览 63
已采纳

jQuery选择框onchange事件

I have a code like this

$(function() {
    $('#book_id').change(function(){
        $('#book_code').show();
        var get_value = $(this).val();
        $( "#book_code" ).html( get_value );
    });
});



<td>
    <select id="book_id" name="book_name" class="form-control">
    <option value="">Select Book</option>
    <?php while($row=mysql_fetch_array($book_query)){?>
        <option value="<?php  echo $row['book_code'];?>">
        <?php  echo $row['book_name']; ?>
        </option>
        <?php  }?>
    </select>
</td>
<td>
    <div id="book_code">
        <input type="text" class="form-control" value="" disabled="disabled" placeholder="Book Code" />
    </div>
</td>

What i want to do is On each select event, i need to show the book code inside a input text box (not editable)

The above code works but doesn't show the value inside the input box

How can I do that?

In other words, on each select event display the book code inside a text box

Thanks, Kimz

  • 写回答

2条回答 默认 最新

  • drduinfu915094 2014-04-10 05:31
    关注

    You may try this (Working Example) :

    $(function() {
       $('#book_id').on('change', function(){
           $('#book_code').find('input').val($(this).val());
       });
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序