469,575 Members | 1,598 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,575 developers. It's quick & easy.

Clear value in a text box using onClick

1
i want to be able to clear the value in the text box as soon as I click on it. I thought the code may be something like this:

onClick="(this.value='')"

Any Suggestions?
May 24 '07 #1
4 116708
r035198x
13,262 8TB
i want to be able to clear the value in the text box as soon as I click on it. I thought the code may be something like this:

onClick="(this.value='')"

Any Suggestions?
Moved to Javascript forum
May 25 '07 #2
If u want to clear all the text box and change other controls to inital mode then u can simply have your controls inside a form and then use the following code
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2. fromreset()
  3. {
  4. myform.reset(); //will reset all the controls in ur page to initial stage.
  5. (or) 
  6. document.myform.[textbox Id] = " "; // will clear the textbox alone
  7. }
  8.  
  9. <form name="myform" id="myform">
  10. your code
  11. may be you have some button ... on that button's onclick option
  12. onclick = "javascript:formreset();">
  13. </form>
  14.  
May 25 '07 #3
gits
5,390 Expert Mod 4TB
i want to be able to clear the value in the text box as soon as I click on it. I thought the code may be something like this:

onClick="(this.value='')"

Any Suggestions?
... what's wrong with it? the following example works just fine (actually tested in IE, MOZ, FF):

Expand|Select|Wrap|Line Numbers
  1. <input type="text" id="tx" name="tx" value="click" onclick="this.value='';"/>
  2.  
post some lines of code where an error occurs

kind regards ...
May 25 '07 #4
mali01
1
It works, I just added:

Expand|Select|Wrap|Line Numbers
  1. onclick="this.value='';"
  2.  
Thanks a lot!
MALI
Feb 17 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by mikea_59 | last post: by
1 post views Thread by Lena | last post: by
1 post views Thread by Bishman | last post: by
4 posts views Thread by research_stuff | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.