...

View Full Version : Highlighting text box contents on click



cyphix
03-13-2005, 05:17 PM
How can you get the contents of a text box to automatically highlight when the user clicks anywhere in the text box?

Thanks much! :)

vwphillips
03-13-2005, 05:29 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>
<title></title>
</head>

<body>
<input name="" size="10" value="fred"
onfocus="javascript:this.style.backgroundColor='#336699';"
onblur="javascript:this.style.backgroundColor='white';"
>
</body>

</html>

afru
03-13-2005, 06:39 PM
Hi,

Are you looking for this?


<input type="text" value="Click on me" onclick="this.select()">

This is to select contents of textbox. If you just want to change color, then you can use vwphilips code. Its a nice one.

Afru.

cyphix
03-13-2005, 07:37 PM
Oh yes.. I meant to select the contents. :o

Thanks guys! :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum