473,387 Members | 1,540 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,387 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 3367
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; }
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.