I’m working on a system and I want to make the system easier to use. I have few forms on a page and huge tables in each. I’m not good at JS so any advice would be appreciated.
Advertisement
Answer
Use a click event listener:
JavaScript
x
6
1
document.body.addEventListener('click', function(e){
2
if (e.button == 1){
3
document.formname.submit();
4
}
5
});
6
EDIT:
As per the new jQuery tag, it’s slightly faster:
JavaScript
1
7
1
$('body').click(function(e){
2
if((!$.browser.msie && e.button == 1) || ($.browser.msie && e.button == 4)){
3
// IE exception thanks to @Elias Van Ootegem
4
$('form.myForm').submit();
5
}
6
});
7