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条)

报告相同问题?