Jump to content

Rating script won't work...


Vigilant Psyche

Recommended Posts

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...

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.