function focus(element) {
document.form.element.focus();
}
I want to have a function to focus on an input box, but it seems I can't do that. Is there a better way to do this?
function focus(element) {
document.form.element.focus();
}
I want to have a function to focus on an input box, but it seems I can't do that. Is there a better way to do this?
If you're passing element directly to the function, call focus directly on that.
function focus(element) {
element.focus();
}
If you're just passing the name of the element to the function, then ..
function focus(element) {
document.form[element].focus();
}