Reputation: 3485
I have a form containing filters and table with checkboxes for different "bulk" actions. Bulk actions should be posted via POST, filters - GET guery. I cannot use 2 different forms and don't want to post actions/filters using AJAX, so I decided to change the form METHOT attribute depending on which button is pressed.
$('button.filter').click(function(){
$(this).closest('form').attr('method', 'get');
});
Basically it works, at least in Opera. I just wondering is this method correct? Any other solutions?
UPD: I decided to simple emulate GET request. Looks less hacky to me
$('thead :submit').click(function () {
var params = $(this).closest('thead').find(':input[name]').filter(function () {
return this.value !== "";
}).serialize();
if(params){
window.location = window.location.href.split('?')[0] + '?' + params;
}
return false;
});
Upvotes: 0
Views: 517
Reputation: 2027
You can use plain JavaScript if you don't want to use jQuery:
document.getElementById("form").method = "post";
Upvotes: 1