PDA

View Full Version : Focusing on most recent input to text area



meisterluv
02-13-2010, 05:19 PM
Hello there I was wondering if there is a way to focus on the most recent input to a text area (say after 50 inputs) without having to manually scroll down??



function console(msg){
document.console1.input.value = document.console1.input.value+=msg
document.console1.input.value.focus()
}



~read that focus() should do it . . . but it doesn't

Thanks!

jscheuer1
02-14-2010, 03:41 PM
I'm not clear if any of that will do anything. But this part:



document.console1.input.value.focus()

should be:


document.console1.input.focus();

The line above it (essentially value = value += msg) seems to want to change the value to its current value plus the value of msg. If so, you've combined two methods, either of which would work on their own:



document.console1.input.value = document.console1.input.value + msg;


document.console1.input.value += msg;


They probably will also work like you have it, but it's overkill. The second method is generally preferred.