princessdeia Posted September 28, 2006 Share Posted September 28, 2006 I want to create an image/text rollover on my site, similar to [url=http://www.deeandjason.co.uk/shop/test.php]this[/url]. All the data is held in a mySQL table. I can get the text part to work, but not the image part.My code so far is, javascript function.... function change(html){ DESCRIPTION.innerHTML=html}....php code....echo "<a href=\"shop.php?c=$cat_id\" onMouseOver=\"change('$cat_description')\" onMouseOut=\"change('DESCRIPTION')\">$cat_name</a><br>"; ....html code....<div id="DESCRIPTION">DESCRIPTION</div> ....Thanks in advanceDee Link to comment https://forums.phpfreaks.com/topic/22356-mysql-and-javascript-image-rollovers/ Share on other sites More sharing options...
michaellunsford Posted September 29, 2006 Share Posted September 29, 2006 I don't see any reference to an image? Link to comment https://forums.phpfreaks.com/topic/22356-mysql-and-javascript-image-rollovers/#findComment-100661 Share on other sites More sharing options...
princessdeia Posted September 29, 2006 Author Share Posted September 29, 2006 That is what I need help with - writing the code to reference the image.Both the array and in the html Link to comment https://forums.phpfreaks.com/topic/22356-mysql-and-javascript-image-rollovers/#findComment-100712 Share on other sites More sharing options...
fenway Posted September 29, 2006 Share Posted September 29, 2006 What image? Link to comment https://forums.phpfreaks.com/topic/22356-mysql-and-javascript-image-rollovers/#findComment-100979 Share on other sites More sharing options...
FrOzeN Posted September 30, 2006 Share Posted September 30, 2006 This works fine, check that your javascript lines of code end with semicolons appropriately.[code]<html><head> <title>example</title> script type="text/javascript"> function change(html) { description.innerHTML = html; } </script></head><body><a href="#" onMouseOver="javascript:change('Over link one!');" onMouseOut="javascript:change('');">Link 1</a><br /> <a href="#" onMouseOver="javascript:change('Over link two!');" onMouseOut="javascript:change('');">Link 2</a><br /><a href="#" onMouseOver="javascript:change('Over link three!');" onMouseOut="javascript:change('');">Link 3</a><br /><hr /><div id="description"></div></body></html>[/code][EDIT] Removed dollar signs.. Link to comment https://forums.phpfreaks.com/topic/22356-mysql-and-javascript-image-rollovers/#findComment-101360 Share on other sites More sharing options...
fenway Posted September 30, 2006 Share Posted September 30, 2006 <shudder> Prefixing JS variables with dollar signs? </shudder> Link to comment https://forums.phpfreaks.com/topic/22356-mysql-and-javascript-image-rollovers/#findComment-101423 Share on other sites More sharing options...
FrOzeN Posted September 30, 2006 Share Posted September 30, 2006 Wow, I'm tired. Don't know what I was thinking there. :-\ Link to comment https://forums.phpfreaks.com/topic/22356-mysql-and-javascript-image-rollovers/#findComment-101473 Share on other sites More sharing options...
michaellunsford Posted September 30, 2006 Share Posted September 30, 2006 Javascript does not like newline in the middle of code. If the variable you're passing has newlines in it it just won't work.I think it would also help us to know what's actually in that variable that's being used in the javascript. Link to comment https://forums.phpfreaks.com/topic/22356-mysql-and-javascript-image-rollovers/#findComment-101479 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.