ferdia Posted November 22, 2010 Share Posted November 22, 2010 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 More sharing options...
jimmyt1988 Posted November 22, 2010 Share Posted November 22, 2010 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> Link to comment https://forums.phpfreaks.com/topic/219515-textbox-background-swap/#findComment-1138168 Share on other sites More sharing options...
ferdia Posted November 23, 2010 Author Share Posted November 23, 2010 That ALMOST worked thank you Jimmy, I'm getting an odd repeating problem with the onBlur, is there anyway to add a no-repeat attribute into the onBlur mix? Ferdia Link to comment https://forums.phpfreaks.com/topic/219515-textbox-background-swap/#findComment-1138184 Share on other sites More sharing options...
jimmyt1988 Posted November 23, 2010 Share Posted November 23, 2010 <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> Link to comment https://forums.phpfreaks.com/topic/219515-textbox-background-swap/#findComment-1138187 Share on other sites More sharing options...
ferdia Posted November 23, 2010 Author Share Posted November 23, 2010 A gentleman and a scholar sir, thanks you very much. Link to comment https://forums.phpfreaks.com/topic/219515-textbox-background-swap/#findComment-1138199 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.