Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > JavaScript > Re: eliminate r...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 19 Topic 36382 of 37166
Post > Topic >>

Re: eliminate results

by "Evertjan." <exjxw.hannivoort@[EMAIL PROTECTED] > Jul 26, 2008 at 10:56 AM

wrote on 26 jul 2008 in comp.lang.javascript:

> Hello.
> 
> I receive from a database a variable number of results.


Seems school assignment to me.

 
> In my page, I can show a maximum of 36 results.
> 
> I want to "neatly" eliminate the exceeding results.
> 
> For example:
> say, we have 40 results.
> I must eliminate 4 results.
> -->I must never eliminate the first and the last.
> 
> So, I have:
> 34-4=30;
> 30/4 returns 7,5 (rounded = 7);
> 
> the elements to eliminate will be:
> 7, 14, 21, 28
> 
> I must automate this procedure...
> 
> I tried the following solution:
> 
> // hardcoded number of results for testing purposes
> totResults = 150;
> // maximum number of items
> maxItems = 36;
> //
> p = totResults/maxItems;
> //
> temp = [];
> for (i=0; i<maxItems+1; i++) {
>         temp[Math.ceil(p*i)] = Math.ceil(p*i);
> 
>}
> 
> The creation of undefined elements is perfectly functional to my
> purposes, so please don't worry about it.
> 
> The fact is that this algorhitm works in a certain number of cases but
> sometimes it doesn't, dued to rounding issues.
> 
> Could someone help me? Thanks!
> 



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 




 19 Posts in Topic:
eliminate results
chilipepas@[EMAIL PROTECT  2008-07-26 01:31:01 
Re: eliminate results
"Evertjan." <  2008-07-26 10:56:43 
Re: eliminate results
Thomas 'PointedEars' Lahn  2008-07-26 13:39:38 
Re: eliminate results
Lasse Reichstein Nielsen   2008-07-27 13:37:06 
Re: eliminate results
Piperita <chilipepas@[  2008-07-26 07:34:44 
Re: eliminate results
"Evertjan." <  2008-07-26 17:41:10 
Re: eliminate results
Thomas 'PointedEars' Lahn  2008-07-26 21:41:22 
Re: eliminate results
Piperita <chilipepas@[  2008-07-27 00:03:44 
Re: eliminate results
"Evertjan." <  2008-07-27 08:28:28 
Re: eliminate results
Piperita <chilipepas@[  2008-07-27 00:13:59 
Re: eliminate results
Piperita <chilipepas@[  2008-07-27 00:14:52 
Re: eliminate results
Piperita <chilipepas@[  2008-07-27 01:48:27 
Re: eliminate results
Piperita <chilipepas@[  2008-07-28 09:47:20 
Re: eliminate results
Thomas 'PointedEars' Lahn  2008-07-28 19:32:47 
Re: eliminate results
Piperita <chilipepas@[  2008-07-28 11:54:41 
Re: eliminate results
Thomas 'PointedEars' Lahn  2008-07-29 01:26:58 
Re: eliminate results
Piperita <chilipepas@[  2008-07-30 02:33:36 
Re: eliminate results
Thomas 'PointedEars' Lahn  2008-07-30 12:36:47 
Re: eliminate results
Piperita <chilipepas@[  2008-07-30 07:11:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 9:40:28 CDT 2008.