I have a textbox that has an image in it that is light grey, explaining what the textbox is about, much like "Google" up the top of your browsers (FF and IE7) where the search bar is.
What I'm trying to do is have it default to the image, but if there is text in it, don't display the image. With the following code, the value is pulled from the database, so it is echoing the value. At the moment, the image appears, whether or not there is text in it, but when i click on it the image goes, as long as there is text still in there. I have it running from page load, so I'm not sure why it is doing anything when i just click in it.
Code: Select all
if (add && add.clientnama) {
var clientnama = add.clientnama;
var b = function () {
if (clientnama.value == "") {
clientnama.style.background = '#FFFFFF url(images/tb-clientname.gif) left no-repeat';
}
else {
clientnama.style.background = '#FFFFFF';
}
}
var f = function() {
clientnama.style.background = '#FFFFFF';
}
clientnama.onblur = b;
clientnama.onfocus = f;
}