how do i change fore color in a textbox with javascript

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jan 2005
Posts: 19
Reputation: sqlchopper is an unknown quantity at this point 
Solved Threads: 1
sqlchopper sqlchopper is offline Offline
Newbie Poster

how do i change fore color in a textbox with javascript

 
0
  #1
Apr 13th, 2006
I tried several things. i get invalid char or no object. can one change fore color or setup a mask. the text box contains numbers and if the number is negitive i need it to show in red, black if not.
var oRed = '#ff0000'
var oBlack = '#000000'
if (parseInt(document.getElementById('nm1TextBox').value) < parseInt(0))
{document.getElementById('nm1TextBox').forecolor = oRed;}
else
{document.getElementById('nm1TextBox').forecolor = oBlack;}
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: how do i change fore color in a textbox with javascript

 
0
  #2
Apr 13th, 2006
You need to access and modify the style collection.

document.getElementById("nm1Textbox").style.color = "red";
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 19
Reputation: sqlchopper is an unknown quantity at this point 
Solved Threads: 1
sqlchopper sqlchopper is offline Offline
Newbie Poster

Re: how do i change fore color in a textbox with javascript

 
0
  #3
Apr 24th, 2006
thanks. i ended up changing the bgcolor. will try this in the next version.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC