duan19740319 2011-07-06 10:26
浏览 16
已采纳

onchange随身携带选定的文字和隐藏价值如何?

I have a dynamically populated PHP dropdown menu that gathers the following information from the database:

echo '<option value="'.$image['id'].'">'.$image['description'].'</option>';

I then have a javascript function that shows the selected text - description in an input box for editing and then on submit update back into the database.

Question: Is there away using javascript that I could pass the id and description together but only have the description show in the input box for editing?

$('#captionSelect').change(function(){
        $('#captionInput').val($("#captionSelect option:selected").text()).show();
    });
  • 写回答

3条回答 默认 最新

  • duanqian6295 2011-07-06 10:32
    关注

    you can try this.

    $('#captionSelect').change(function(){
            $('#captionInput').val($("#captionSelect option:selected").html()).show();
        });
    

    Thanks.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥50 adb连接不到手机是怎么回事?
  • ¥15 vs2022无法联网
  • ¥15 TCP的客户端和服务器的互联
  • ¥15 VB.NET操作免驱摄像头
  • ¥15 笔记本上移动热点开关状态查询
  • ¥85 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,
  • ¥15 docker实践项目