Vigilant Psyche Posted July 24, 2008 Share Posted July 24, 2008 Hi. I'm tyring to make a little script to highlight a series of stars up until where you hover (youtube style). But my script won't work: function rate_show(num) { var i=0; for(i=0;i<num;i++) { document.GetElementById(i).src="images/rate.png"; } var j=0; var not=5-num; for(j=0;j<not;j++) { document.GetElementById(j).src="images/rate_off.png"; } } Anything obvious wrong? ??? HTML is as follows: <image src='images/rate_off.png' id='0' onmouseover='rate_show(0)'/> <image src='images/rate_off.png' id='1' onmouseover='rate_show(1)'/> <image src='images/rate_off.png' id='2' onmouseover='rate_show(2)'/> etc... Quote Link to comment Share on other sites More sharing options...
lemmin Posted July 24, 2008 Share Posted July 24, 2008 getElementById starts with a lowercase 'g'. Aside from that, the logic of your "not" part doesn't really work. You can do something like this: <html> <head> <script language="JScript"> function rate_show(e) { for(var i=0;i<=e.id;i++) { document.getElementById(i).src="images/rate.png"; e.onmouseout=function() { e.src="images/rate_off.png"; } } } </script> </head> <bodY> <image src='images/rate_off.png' id='0' onmouseover="rate_show(this)"><image src='images/rate_off.png' id='1' onmouseover="rate_show(this)"><image src='images/rate_off.png' id='2' onmouseover="rate_show(this)"><image src='images/rate_off.png' id='3' onmouseover="rate_show(this)"><image src='images/rate_off.png' id='4' onmouseover="rate_show(this)"> </body> </html> Quote Link to comment Share on other sites More sharing options...
Vigilant Psyche Posted July 29, 2008 Author Share Posted July 29, 2008 Thanks that works great! 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.