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 Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
fenway Posted September 29, 2006 Share Posted September 29, 2006 What image? Quote Link to comment 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.. Quote Link to comment 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> Quote Link to comment 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. :-\ Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.