473,770 Members | 6,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Textbox Color if Value=

1 New Member
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 1321
acoder
16,027 Recognized Expert Moderator MVP
To change the colour, use formElement.sty le.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
15726
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 Record button is clicked. The code checks the table for the highest value and then assigns 1 and inserts the value. I have a second text box which needs the same type of custom auto-number which has to be generated from a second command button. ...
9
10120
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, possibly a custom validator with a function written in javascript. Has anyone done this? Does someone have an example? Regards
1
6709
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 assign a value to this textbox using Javascript with 'Form1.TextBox1.Value = "Hello"' But when I want to read the value of this Textbox later on using VB with 'MyVar = TextBox1.Text' it returns nothing.
5
14776
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 postback occurs. Why is this? I want the textbox to become empty after postback. How can I do it without setting textbox.text = "" and without doing Response.redirect to the same page. JK
7
2141
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 following: (TextBox)UserPrefix=(TextBox)e.Item.Cells.Controls; string strUserPrefix=UserPrefix.Text; I keep getting the following error and I don't know why because I have declared the UserPrefix as a textbox using "protected...
3
3995
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='<% =Server.HtmlEncode(Request.Cookies("Username")("Username"))%>'> i have created a cookie and want to use it with my login page. I currently have asp:TextBox with form validation control. I can get the cookie value to appear but not in the asp:TextBox. I can use a...
11
4578
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 opinion of how I want to handle the 'user experience' in the application I'm creating. While I know I could allow the user to enter in number and alpha text - in a text box - and then tell them when the execuate a command "This is not numeric data", I...
2
12599
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 first column is a textbox(TemplateColumn), the other 3 columns are just display(BoundColumn). (1) if the value of the textbox is 0, then i'd like to change it null, so the box is empty
2
3167
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 to control if any of these text boxes is empty or are we really forced to do it on a one by one basis doing If....End is so many times?
2
12945
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 textboxid in javascript .my code is function validation() { alert("hi")
0
9591
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
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10053
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10001
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
9867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6676
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
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3969
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
3
2816
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.