DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   starrating (http://www.daniweb.com/forums/thread79648.html)

ytregnn May 30th, 2007 2:28 pm
starrating
 
http://www.masugadesign.com/the-lab/...ar-rating-bar/

Does anyone know how I could do a top 10 list within a table that has every second "table" in diferent colors with different pictures that will show up based up on the rating is an odd or even number (1=blue 2= grey, 3,=blue, ect.)

Look at this picture if it doesnt make sense

http://www.pokerdream.tk/lookhere.jpg

Dukane May 30th, 2007 5:29 pm
Re: starrating
 
As you are iterating through the table, count rows. If the row number is odd, make it blue. If not, make it grey.

ytregnn Jun 6th, 2007 4:03 pm
Re: starrating
 
Hmm.. can it be so simple? To me, when I see the "toplist"-code I feel it could be alot harder (??).

Dukane Jun 7th, 2007 9:18 am
Re: starrating
 
Whoops! I'm sorry I misread your problem. But the solution (to what I think you want to do) isn't too far off.

As you are reading through the list of Top 10, divide the rating by 2. If the result comes out as an integer, the rating was EVEN. (0, 2, 4, 6, 8 or 10). If the result has a fractional part the rating will be ODD (1, 3, 5, 7, 9 - these numbers are not equally divisible by 2).

As you get this even/odd information, set it to a variable--say a boolean variable. If the variable is true, then color the table one way (say blue for even) and if it is false, then color the table the other way (say grey for odd).

ytregnn Jul 29th, 2007 10:42 am
Re: starrating
 
Hmm..

How can I do that - I'm not the best programmer..

??

ytregnn Aug 7th, 2007 10:30 am
Re: starrating
 
Can someone help me ?

MidiMagic Aug 8th, 2007 1:04 am
Re: starrating
 
Integer division:

a = Math.floor(b/2);

Test for odd:

a = Math.floor(b/2);
if(b - a*2 > .0001){
  // code if b is odd

}
else{
  // code if b is even

};

ytregnn Aug 9th, 2007 4:31 pm
Re: starrating
 
thank you, I'll see if I can make it right in someway-


All times are GMT -4. The time now is 9:21 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC