Hello All, this is my first post and I am about to pull my hair out. Does anyone know of a reference that can tell you all the properties or methods accessible through javascript for the form element: textbox.
I am trying to manipulate a background image of a textbox between when the user clicks in the box triggering onfocus and when the user leaves the box triggering onblur.
Here is the code for what I am doing:
[CODE] HTML
<form name=”frmSearchWebster” id=”frmSearchWebster”>
<input type=”text” id=”txtSearchWebster” name=”txtSearchWebster” onfocus=”changeSearchBG(1)” onblur=”changeSearchBG(0)”/>
</form>
[CODE] CSS
#frmSearchWebster #txtSearchWebster {
background:url(/images/searchBG.gif);
}
[CODE] Javascript
function changeSearchBG(opt){
var toggle = opt;
if (toggle=0)
{
document.frmSearchWebster.getElementByID(‘txtSearchWebster’).style.Background = ‘url(/images/searchBG.gif)’;
}
else if (toggle=1 && document.frmSearchWebster.getElementByID(‘txtSearchWebster’).Value=””)
{
document.frmSearchWebster.getElementByID(‘txtSearchWebster’).style.Background = ‘url(/images/spacer.gif)’;
}
}
With this code, when I click in the text box i get a script error that says:
“Object doesn’t support this property or method”
When I go into the script debugger it highlights this line:
“document.frmSearchWebster.getElementByID(‘txtSearchWebster’).style.Background = ‘url(/images/searchBG.gif)’;”
I have tried the property “Background” with an upper and lower case b and same thing. So is this the wrong syntax or is this even possible.
I have another way of accomplishing this but theres no way to add in logic to test whether or not there is text in the textbox before switching the background.
Thanks for any help