View Single Post
Join Date: Aug 2006
Posts: 315
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

Re: onclick text box?

 
0
  #2
Dec 2nd, 2008
You have to write a handlers for onfocus and onblur events for this textbox like this:

  1.  
  2. <form>
  3. <input type="text" value="Email" name="Email" style="color:grey;text-align:left;background:white" onfocus='changeTextColor(this, 1)' onblur='changeTextColor(this, 0)'>
  4. </form>

And your handlers will look like this:

  1. function changeTextColor(tBox, c) {
  2. if(c==1) { //textbox on focus
  3. tBox.style.color = "black";
  4. } else { //textbox out of focus
  5. tBox.style.color = "grey";
  6. }
  7. }
Last edited by Luckychap; Dec 2nd, 2008 at 12:28 am.
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote