•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 374,027 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,877 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1370 | Replies: 7
![]() |
•
•
Join Date: Jun 2006
Posts: 41
Reputation:
Rep Power: 3
Solved Threads: 0
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
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
As you are iterating through the table, count rows. If the row number is odd, make it blue. If not, make it grey.
It is very important to read this: http://www.catb.org/~esr/faqs/smart-questions.html
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).
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).
It is very important to read this: http://www.catb.org/~esr/faqs/smart-questions.html
Integer division:
Test for odd:
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
}; Daylight-saving time uses more gasoline
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- Previous Thread: Javascript: Child windows talking to each other???
- Next Thread: Window.createPopup() in firefox?



Linear Mode