jonnewbie12 Posted November 2, 2011 Share Posted November 2, 2011 I am designing a PHP page in dreamweaver CS5. I have a tabe with a background image. Is there a simple code that will allow me to change the image preferably on a hover or a click. Ideally I want to get the image from the database using echo function. I have called the table ID "td1". Table code is: <table width="89%" border="0" cellpadding="0" cellspacing="2" style="background:url(graphics/colourboxcream.png) no-repeat" id="td1"> Please, please, help Link to comment https://forums.phpfreaks.com/topic/250323-change-table-background-image-on-click/ Share on other sites More sharing options...
freelance84 Posted November 2, 2011 Share Posted November 2, 2011 Sounds like a javascript. This came up on a google search: http://www.webdeveloper.com/forum/showthread.php?t=173149 If you dont need the image to remain the same, then use css :hover or :active Link to comment https://forums.phpfreaks.com/topic/250323-change-table-background-image-on-click/#findComment-1284398 Share on other sites More sharing options...
jonnewbie12 Posted November 2, 2011 Author Share Posted November 2, 2011 easy to say and I am using CSS but I cant work out what the code is to change the background. Not sure how to define the table. Is it a get element ID or a table.id.background-image or some other code to point to the actual table? Sorry for being a div but I know how to change the image and how to use CSS but I am having trouble trying to work out the the actual function that will change the property when clicked or hovered? Link to comment https://forums.phpfreaks.com/topic/250323-change-table-background-image-on-click/#findComment-1284416 Share on other sites More sharing options...
joe92 Posted November 2, 2011 Share Posted November 2, 2011 document.getElementById('id').style.backgroundImage="url('img.png')"; Should do it. Link to comment https://forums.phpfreaks.com/topic/250323-change-table-background-image-on-click/#findComment-1284438 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.