469,314 Members | 2,239 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

js function to clear field when action="onclick"

I could use some help to update these functions to only allow the clear and color update on the first onclick and not the second or third etc.

Upon entering the site the field includes some suggested text. When the onclick is issued the field updates and resets the color and text. What isn't required is if the field is clicked again no to repeat the color and text.

Suggestions?

Expand|Select|Wrap|Line Numbers
  1. function clearText(thefield) { 
  2.     if (thefield.defaultValue == thefield.value) thefield.value = "" 
  3.     else thefield.value = thefield.defaultValue 
  4.  
  5. function changeInColor(thefield) { 
  6.     if (thefield.defaultValue == thefield.value) 
  7.       queryForm.QueryText.style.background= "#CCCCCC" 
  8.     else queryForm.QueryText.style.background= "#FFFFFF" 
  9. }
Jul 25 '07 #1
3 3157
pbmods
5,821 Expert 4TB
swebster, please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
Jul 25 '07 #2
gits
5,390 Expert Mod 4TB
hi ...

for such a task the simplest solution is to init a global variable in page-init (may be onload of the page) with 0 and then when the field is clicked to increase the value by 1 ... and! ask for the value <= 1 to to the action else do nothing ... so its called only one time ...

kind regards
Jul 25 '07 #3
hi ...

for such a task the simplest solution is to init a global variable in page-init (may be onload of the page) with 0 and then when the field is clicked to increase the value by 1 ... and! ask for the value <= 1 to to the action else do nothing ... so its called only one time ...

kind regards
sounds good. thanks.
Jul 26 '07 #4

Post your reply

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

Similar topics

5 posts views Thread by johnsuth | last post: by
2 posts views Thread by Peter | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.