tags:

views:

52

answers:

2

I want to be able to just click inside a text field, so that it highlights all the text inside it (and possibly also copies it). Although, I'm satisfied with just getting it highlighted if that's possible with HTML only. Many people are using NoScript and such nowadays, so I'm trying to stay away from JavaScript etc.

TinyPic is one example which uses this little 'feature'.

Thanks for your help.

A: 

I'm pretty sure you need to use some javascript; no matter how trivial it might be.

For example; this does what you're asking:

<input type="text" value="Click Me to Select Text" onclick="this.select()">
Jim B
Thanks a lot.Yeah, it looks like I'm going to have to use JavaScript after all...
Nisto
A: 

in the head section add this script:

    <script language="JavaScript">
    function highlight(field) {
    field.focus();
    field.select();}</script>

And then for each field that you want to select all the text in when clicked, add this:

onClick='highlight(this);

I hope it works, try it by the way

Sohail