473,387 Members | 1,520 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.

Textbox Color if Value=

Hi

I am kinda a noob when it comes to coding, but I have been doing some html, javascript etc. I'm creating a stopwatch (using a code I found and edited a little bit) But I need to make one change, I want the text box's to change form one color to another when the time goes past 900seconds, or 15 minutes. Here is the script I'm using...

Expand|Select|Wrap|Line Numbers
  1.  
  2. <html>
  3. <head>
  4.  
  5. </head>
  6.  
  7. <body bgcolor="#000000">
  8.  
  9. <center>
  10.  
  11.  
  12. <font color="#FFFFFF">
  13. <h2>Stopwatch</h2>
  14. </font>
  15.  
  16. <form name=exf1> <font color="#FFFFFF"><b>
  17. H: <input size=1 type=text name=hour  value="0" onfocus=blur()>&nbsp;
  18.  
  19. M:  <input size=2 type=text name=tmin   value="0" onfocus=blur()>&nbsp;
  20.  
  21. S:  <input size=3 type=text name=sec   value="0" onfocus=blur()>&nbsp;
  22.  
  23. </b></font>
  24.  
  25. <br><br>
  26.  
  27. <input type=button value="Start / Reset" onclick="startIt()">
  28. <input type=button value="Stop" onclick="stopTimers()">
  29. </form>
  30.  
  31.  
  32. <script>
  33. var _myTimer_ms = null;
  34. var _myTimer_s  = null;
  35. var _myTimer_m  = null;
  36. var _myTimer_h  = null;
  37. function updateS()  { document.exf1.sec.value   = (1+parseInt(document.exf1.sec.value))  }
  38. function updateM()  { document.exf1.tmin.value  = (1+parseInt(document.exf1.tmin.value))  }
  39. function updateH()  { document.exf1.hour.value  = (1+parseInt(document.exf1.hour.value));  }
  40. function startIt() {
  41.   stopTimers();
  42.   resetTime();
  43.   _myTimer_s  = setInterval("updateS()",1000);
  44.   _myTimer_m  = setInterval("updateM()",1000*60);
  45.   _myTimer_h  = setInterval("updateH()",1000*60*60);
  46. }
  47. function stopTimers() {
  48.   clearInterval(_myTimer_s);
  49.   clearInterval(_myTimer_m);
  50.   clearInterval(_myTimer_h);
  51. }
  52. function resetTime() {
  53.   document.exf1.sec.value=0;
  54.   document.exf1.tmin.value=0;
  55.   document.exf1.hour.value=0;
  56. }
  57.  
  58. </script>
  59.  
  60. </center>
  61.  
  62. </body>
  63. </html>
  64.  
  65.  
I'm sure this would be possible with a If function, but I learn C++ back in the day(not a lot) and the one i wrote, for C, did not convert well. any help would be appreciated.

Thank You
Kirt
Mar 10 '08 #1
1 1296
acoder
16,027 Expert Mod 8TB
To change the colour, use formElement.style.color = 'the color' where formElement is the element to change. You can use setTimeout to call the function to change it after 1000*60*15 milliseconds.
Mar 10 '08 #2

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

Similar topics

2
by: dskillingstad | last post by:
I'm trying to assign a custom value to a textbox. Here's what I have. I've created a module and "default value" code for a textbox which generates a custom auto-number (yyyy-0000) when a New...
9
by: Jerry | last post by:
In limiting textbox input to 500 characters I would like to include a dynamic count of characters input while the user is typing into a textbox. This would obviously be a client side control,...
1
by: Martin | last post by:
Dear Group Sorry for bothering you again but I need expert advice on this. I have placed a HTML textbox on my aspx form and converted it to run as a server control. At some point in my code I...
5
by: JollyK | last post by:
Hello all, I have always been having this issue and wondering what the solution is. When I set the enableviewstate property to false for a textbox, the textbox always retains its value after a...
7
by: I am Sam | last post by:
I have a DataGrid that is passing information to a stored procedure properly but the parameters aren't being casted properly. I was woundering if anyone can tell me how I should properly cast the...
3
by: Justin Morris via DotNetMonster.com | last post by:
<asp:TextBox ID="TextBox1" runat="server" value='<%=Server.HtmlEncode (Request.Cookies("Username")("Username"))%>'/> <input name="Password" type="text" id="Password" value='<%...
11
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing...
2
by: simon | last post by:
hello, new to vb.net, have a few questions about DataGrid. I have a dataGrid that is working pulling a dataset back from a stored proc and binding to the datagrid for display the datagrid's...
2
by: Adam Honek | last post by:
I have a form. It has serveral text boxes for user data entry. I could of course write code to check if each is empty before proceeding to save this data to a file. Is there any global way...
2
by: mrutyunjaya | last post by:
hello, i have two textbox column and one button control in gridvie when i click button it will ask plese enter price in first textbox . when enter values it is asking again. how to pass...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.