New useful function submitFormById(). Fires off the form's onsubmit() handler first,

if applicable, and only submits if the handler doesn't exist or returns true.
This commit is contained in:
defacer
2005-03-08 04:22:38 +00:00
parent 80117b519d
commit 7678e65cac

View File

@ -56,3 +56,16 @@ function unlockoption(form,item) {
eval("document."+form+"."+item+".disabled=false");/* IE thing */
eval("document."+form+".h"+item+".value=0");
}
function submitFormById(id) {
var theform = document.getElementById(id);
if(!theform) {
return false;
}
if(theform.tagName != 'FORM') {
return false;
}
if(!theform.onsubmit || theform.onsubmit()) {
return theform.submit();
}
}