Jump to content

Textbox Background Swap


ferdia

Recommended Posts

Hi guys, simple one for you. I have two text boxes that I want to change the background image of, onFocus.

 

Here is the text boxes:

<td><input type="text" name="user" maxlength="30" value="" id="userbox"></td>
<td><input type="password" name="pass" maxlength="30" value="" id="passbox"></td>

 

And here is the CSS that adds the background images:

#userbox {
background-image:url('../images/username.png');
background-repeat:no-repeat;
}

#passbox {
background-image:url('../images/password.png');
background-repeat:no-repeat;
}

 

Any ideas on how I would switch the backgrounds to another image? Lets say blank.png?

 

Thanks in adance.

Link to comment
https://forums.phpfreaks.com/topic/219515-textbox-background-swap/
Share on other sites

try this: 

<td>
     <input onfocus = "this.style.background = 'url(blank.png)'" onblur = "this.style.background = 'url(original.png)'" type="text" name="user" maxlength="30" value="" id="userbox">
</td>
<td>
     <input onfocus = "this.style.background = 'url(blank.png)'" onblur = "this.style.background = 'url(original.png)'" type="password" name="pass" maxlength="30" value="" id="passbox">
</td>

 

<td>

    <input onfocus = "this.style.background = 'url(blank.png) no-repeat'" onblur = "this.style.background = 'url(original.png) no-repeat'" type="text" name="user" maxlength="30" value="" id="userbox">

</td>

<td>

    <input onfocus = "this.style.background = 'url(blank.png) no-repeat'" onblur = "this.style.background = 'url(original.png) no-repeat'" type="password" name="pass" maxlength="30" value="" id="passbox">

</td>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.