Skip to content

Instantly share code, notes, and snippets.

@FernandoBasso
Created October 18, 2017 15:58
Show Gist options
  • Save FernandoBasso/cbe8d6d927b5bb19d1652c6600d1c809 to your computer and use it in GitHub Desktop.
Save FernandoBasso/cbe8d6d927b5bb19d1652c6600d1c809 to your computer and use it in GitHub Desktop.
Marvelous piece of javascript found in a legacy project I am maintaining
function foco(formulario){
elementos = document.getElementById(formulario).elements;
for (i=0; i<elementos.length; i++) {
if (elementos[i].hasAttribute("setFocus")) {
obr = elementos[i].getAttribute("type");
if(obr == "text") elementos[i].select(); else elementos[i].focus();
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment