开发者

Delete contents of textbox and automatically deleting another

开发者 https://www.devze.com 2023-04-08 15:41 出处:网络
I have 2 input box fields, one linked to an autocomplete and the other is hidden I have an action on select that takes the id of the selected item into开发者_C百科 the hidden field.

I have 2 input box fields, one linked to an autocomplete and the other is hidden

I have an action on select that takes the id of the selected item into开发者_C百科 the hidden field.

code:

    $('#id_emp_name').autocomplete({
    source: '/mycompany/employees.json',
    minLength: 1,
    dataType: 'json',
    max: 12,
    select: function(event, ui) {
        $('#id_emp_id').val(ui.item.id);

    }
});

I want to change it so that whenever I delete contents (even a single character) on the autcomplete textbox it would set the hidden textbox's to ''


Would this work for you?

$('#id_emp_name').autocomplete({
    source: '/mycompany/employees.json',
    minLength: 1,
    dataType: 'json',
    max: 12,
    select: function(event, ui) {
        $('#id_emp_id').val(ui.item.id);

    }
}).keyup(function(){
    $('#id_emp_id').val('');
});

You may need to put some conditions on it of course.

0

精彩评论

暂无评论...
验证码 换一张
取 消