0

Hi,

I need help no this web page that i'm making, I think it's a bit too simple for you guys :), so here goes nothing....

I need a text box like:

<input value="Click here to clear text" name="nome" type="text">

That actually clears the text when you click on it...

I tried the onClick="" tag but as I looked up it´s just for buttons, right?

Hoping somebody can help me out, yours trully: Braga_ESI

Edited by Dani: Fixed formatting

8
Contributors
11
Replies
32
Views
10 Years
Discussion Span
Last Post by fizerahmani123
Featured Replies
  • onClick will work on most elements, onfocus is more appropriate for a text input, as tabbing to a field also counts as focus... try: [code] <input type="text" value="Click here to clear text" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;"/> [/code] it will only clear the text once.. i assume you want to actually put something in … Read More

0

you can use "onfocus"

<script language="javascript">
<!--
function clearinputText() {
  document.frm.name.value= "";
}

//-->
</script>
<input type="text" name="name" value="Click here to clear text" onfocus="clearinputText();">

but this will clear the text every time when you get focus on this field,

Its a simple example only

best regards
Rahul

1

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,,

0

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,,

Thanks a lot for the help!!! My problem is solved... :lol: Sorry about my english, it's a little rustty...

0

you can use "onfocus"

<script language="javascript">
<!--
function clearinputText() {
  document.frm.name.value= "";
}

//-->
</script>
<input type="text" name="name" value="Click here to clear text" onfocus="clearinputText();">

but this will clear the text every time when you get focus on this field,

Its a simple example only

best regards
Rahul

Thank you very much!!! You gave me a solution that envolves javascript :) that is interesting... :)
ho!, and sorry about my english... :confused:

0

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.

0

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:

0

<html>
<input type="reset" value="Reset!">

</html>

this code doesn't clear textboxes

0
<html>
<body>
<!--Data-->
<form>
Full Name:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" size="30"/></br>
E-mail Address:
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" size="30"/></br>
Password:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="password" size="30"/></br>
Repeat Password:&nbsp;<input type="password" size="30"/></br>

<!--buttons-->
<a href="regsuccess.html">
<input type="submit" value="Register">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" value="Clear"/>
</form>

</body>
</html>

try it..

0

Please Try this <marquee style="font-weight: bold;scrollamount:4;scrolldenay:78;width:500;"> This code is for text moving.
by fizeRahmani India
mob: 7860734527

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.