You can use delegate and attach only 1 handler for each of the type of buttons. It will take care of any number of buttons click event. Try this.
$(document).delegate('input[id=^"ok_"]', 'click', function(){
//Write code here
}).delegate('input[id=^"cancel_"]', 'click', function(){
//Write code here
});
.delegate() reference: http://api.jquery.com/delegate/
If you are using jQuery ver 1.7+ then you can use on with is similar to delegate except for the first 2 arguments interchanged.
$(document).delegate('click', 'input[id=^"ok_"]', function(){
//Write code here
}).delegate('click', 'input[id=^"cancel_"]', function(){
//Write code here
});
Note: In the above code it is always better to provide a container which will contain those elements instead of specifying document to reduce the scope.