PDA

View Full Version : TextArea Highlight


avaloncm
11-19-2004, 03:53 PM
I am using a textarea box in a web page. I want to populate the textarea with text, but have it automatically highlighted so the user only has to start typing. How is this done? Thank you!

dizzle
11-19-2004, 04:37 PM
javascript:

window.onLoad = function () {
var ta = document.getElementById("yourTextAreasID");

ta.focus();
ta.select();
}

coothead
11-19-2004, 04:45 PM
Hi there avaloncm,

try it like this...
<body onload="document.forms[0][0].focus()">

<form action="#">

<div>
<textarea></textarea>
</div>

</form>

avaloncm
11-19-2004, 05:13 PM
Thanks guys!

I changed .focus to .select on the last post and that did the trick.