Select all from textarea/ text input on onclick event

Jun 17th, 2007

Here when an user click on a text link "select all", all the contents of the textarea will be highlighted. You can use onclick event directly on textarea also.

<script type="text/javascript">

function select_all(element1) {
// first set focus
document.frm1.elements[element1].focus();
// select all contents
document.frm1.elements[element1].select();
}
</script>

<form name="frm1">
<a href="#" onclick="select_all('desc')">Select all</a>
<textarea name="desc" cols="50" rows="7"></textarea>
</form>

 

 

Possibly Related posts:

  1. Rodrigo
    June 22nd, 2007 at 21:08 | #1

    Oi, achei teu blog pelo google tá bem interessante gostei desse post. Quando der dá uma passada pelo meu blog, é sobre camisetas personalizadas, mostra passo a passo como criar uma camiseta personalizada bem maneira. Até mais.

Comments are closed.