onClick will work on most elements, onfocus is more appropriate for a text input, as tabbing to a field also counts as focus...
try:
<input type="text" value="Click here to clear text" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;"/>
it will only clear the text once.. i assume you want to actually put something in the text afterwards,,
MattEvans
Veteran Poster
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64
Thank you very much!!! You gave me a solution that envolves javascript that is interesting...
ho!, and sorry about my english...
mine is a javascript solution aswell, but it's all squashed into one parameter line. you could expand it to:
<script type="text/javascript">
function checkclear(what){
if(!what._haschanged){
what.value=''
};
what._haschanged=true;
}
</code>
<input type="text" value="Click here to clear text" onfocus="checkclear(this)"/>
and then use "checkclear(this)" as the onfocus property for all text inputs that you want to have the same behaviour.
MattEvans
Veteran Poster
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64
eeek >_< i hate those buttons!
if you've just spent umpteen minutes finding information and filling out a form; would you EVER want to reset it rather than submit it?
how about this one?
<input type="reset" value="Submit!">
EDIT: :lol:
MattEvans
Veteran Poster
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64