473,671 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

js function to clear field when action="onclick "

34 New Member
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 3383
pbmods
5,821 Recognized Expert Expert
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 Recognized Expert Moderator Expert
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
swebster
34 New Member
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
9929
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 links in my fireworks-generated dhtml popup menus. Does anyone here know where I would add this javascript fucntion in the code so that it would be recognized? And do I do it in the html, or in the JS file? The javascript function I need to add is...
5
17688
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 fancy style, but the onclick fails to do anything no matter what permutation of parameters I try. <input type=button style=background-color:yellow;color:blue;font-family:Arial;font-style:italic;font-weight:bold name="xyz" value="CHANGE COLOUR"...
2
8047
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 inserttable() {
2
7707
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 submit button to submit a form that contains one or two Mileposts: 1) If a Milepost range larger than 5 miles is entered, I would like to pop up a confirmation box to confirm the range.
13
38573
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. However, this is not the case with the IE7 I am using. What has changed?
1
9155
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 button, its work but the values were not insert into the database, its null!! this is my function save_all() look like:- <script language="JavaScript" type="text/javascript"> function simpan() { window.open("signDaftar.cfm"); ...
13
7802
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 statement used in calling the function validateForm rather than being included inside the function? Thanks in advance,
3
1757
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" when a radio button is selected but BEFORE executing "parent.mySub()". Can anyone help me with the required code? Thanks
5
8673
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
8476
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8914
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8598
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7433
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5695
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4224
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2810
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1809
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.