views:

93

answers:

1

I have two dropdown box. 1st box having list of values. When I click add button the selected value from dropdown1 shift to dropdown2. Then when I click "add all" button all the values from list will shift from dropdown1 to dropdown2 through jQuery. Here I am having problem.

After add the values from box1 to box2 when I click submit button the scrolldown of dropdown is automaticaly scrolling one time then only values will be submit. How can I avoid this. Here they are adding the list of values one by one to another box... how can I avoid this.

Using below Jquery i did multiselect. In that Jquery When i click Submit button I was called one function.Through that function i am using one loop .Now i need to avoid that loop.but i need to get the same value.How can i do this

jQuery(function($) {

    var id = '"+desc.getName()+"_"+desc.getId()+"';

    var selectedValues = 'selected_"+desc.getName()+"_"+desc.getId()+"';

    * * * $('input[type=submit]').click(function() {
        var arr = [];
        $('#' + selectedValues + ' option').each(function(i, option) {
            arr[i] = $(option).val();
            $('#' + selectedValues).val(arr);
        });
    }); * * *

    $('#' + id + '').dblclick(function() {
        !$('#' + id + ' option:selected').remove().appendTo('#' + selectedValues);
        var arr = [];
        $('#' + selectedValues + ' option').each(function(i, option) {
            arr[i] = $(option).val();
            $('input[type=submit]').click(function() {
                $('#' + selectedValues).val(arr);
            });
        });
    });

    $('#' + selectedValues + '').dblclick(function() {
        !$('#' + selectedValues + ' option:selected').remove().appendTo('#' + id);
        var arr = [];
        $('#' + selectedValues + ' option').each(function(i, option) {
            arr[i] = $(option).val();
            $('input[type=submit]').click(function() {
                $('#' + selectedValues).val(arr);
            });
        });
    });

    $('input[type=button]').click(function() {
        var id = $(this).attr('id');

        var clickEvent = $(this).attr('clickEvent');
        var selectedValues = $('#selected_' + id).attr('id');

        if (clickEvent == 'add') {
            !$('#' + id + ' option:selected').remove().appendTo('#' + selectedValues);

        } else if (clickEvent == 'addAll') {
            !$('#' + id + ' option').remove().appendTo('#' + selectedValues);

        } else if (clickEvent == 'removeAll') {
            !$('#' + selectedValues + ' option').remove().appendTo('#' + id);

        } else {
            !$('#' + selectedValues + ' option:selected').remove().appendTo('#' + id);
        };;
    });
});

Thanks in advance,

A: 

The code is not understandable.

Dev
Use comments for this. This is not an answer.
Garis Suero