views:

26

answers:

2

below is how i disable all submit button on click

$('form').submit(function(){
    // On submit disable its submit button
    $('input[type=submit]', this).attr('disabled', 'disabled');
});

how to disable all selectbox onchange easily for all selectbox in the page

+1  A: 

Something like this will disable all select boxes:

$('select').attr('disabled', 'disabled');

To tie it to a form submission you can add it to your existing function.

To bind this to a select box's onChange event you can use jQuery's change listener. So if you want all select boxes disabled when any select box changes you can use this:

$('select').change(function(){
    $('select').attr('disabled', 'disabled');
});

If you want to operate on a specific select box you can change the first $('select') above to reference that box.

Mark E
but i only want to disable all selectboxes when "selectbox onchange" event is called
cometta
@cometta: okay, updated.
Mark E
+1  A: 

Almost the same as what you're doing above, just change it to select

$('form').submit(function(){
    // On submit disable its submit button
    $('select', this).attr('disabled', 'disabled');
});
Marko
but i only want to disable all selectboxes when "selectbox onchange" event is called
cometta
That doesn't make sense, you want to disable it as soon as someone changes a value inside the select?
Marko