473,233 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,233 software developers and data experts.

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

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

Similar topics

6
by: Yvan J. Gagnon | last post by:
I am currenly developing a web site using Macromedia fireworks, and am trying to figure out a way (through hand-coding) of attaching a javascript function (onClick="doit=false") to each of the...
5
by: johnsuth | last post by:
I want to produce a trivial demonstration of dynamic modification. I thought that pressing a button might change its color. I studied O'Reillys books and successfully created the button with a...
2
by: Peter | last post by:
Hi, this is the code, and new row and new cell generated ok, but why the onclick and onmouseover doen't work? Thank you in advance! <html> <head> <script language="javascript"> function...
2
by: bay_dar | last post by:
Hi, I have an internal ASP.NET application that I'm are using to send e-mails out based on a single milepost or milepost range entered. I'm trying to do two things when a user clicks on the...
13
by: alvin.yk | last post by:
Hi, Normally, a piece of code such as <a href="http://www.yahoo.com" onclick="alert('hello');return false;">link</a> will stop the browser from actually going to href's destination....
1
by: rozx | last post by:
how to pass input value form a page into a database using this onClick function. <input type="button" name="save" value="SIMPAN" onClick="save_all()"> i've tried a few times, each time i click the...
13
by: Steve | last post by:
On page 392 of "Javascript the definitive guide" a function is called like this:- <form action="processform.cgi" onsubmit="return validateForm();"> Why, in this instance, is the return...
3
by: PVACC | last post by:
I have a line of code thus: w3('<input type=radio name=rad onclick="parent.mySub('+i+')">'); The function w3() writes the code in an iframe. I need to set a variable "start" to the value "1"...
5
by: dangt85 | last post by:
Hello, I have the following page: ... <style type="text/css"> body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.