$('select[id^='Branch]').change(function(){ var idx = this.id.substr(this.id.length - 1); var selected = $(this).val(); ajax_loading_image('.ajax_loading_image'); $.ajax({ type: "POST", url: 'get_members', data: "ajax=true&id="+selected, success: function(data){ $('.Comaker' + idx).html(data); // remove loading image ajax_remove_loading_image('.ajax_loading_image'); } }); });
extra note: no need to ".clear" before ".html" On Feb 28, 4:28 am, ramonmaruko <ramonmar...@gmail.com> wrote: > Is there a 'better' way of doing this? I think that the code is dirty > since a lot of things are being repeated elsewhere. Tips, hints, > links, etc would be appreciated. Thank you. > > JQuery code:http://pastebin.com/m3b0c63fb > > HTML form code:http://pastebin.com/m664f5de6