theninjamanz 29 Posted June 10, 2010 Report Share Posted June 10, 2010 How can I make ubot loop to one decimal place? I have a UI text box where the user puts in a numeric value: EG 87. I then have to do a division of that to get the actual number of loops the script will run. In this case the division is 10. How can I tell ubot to loop 9 times instead of the 8.7 times (which is impossible) it will if I leave it as it is. ThanksNinjman. Quote Link to post Share on other sites
Net66 54 Posted June 10, 2010 Report Share Posted June 10, 2010 How can I make ubot loop to one decimal place? I have a UI text box where the user puts in a numeric value: EG 87. I then have to do a division of that to get the actual number of loops the script will run. In this case the division is 10. How can I tell ubot to loop 9 times instead of the 8.7 times (which is impossible) it will if I leave it as it is. ThanksNinjman. You can do this with javascript; The javascript function Math.ceil chooses the nearest integer to your original number but not less than. So if you pass it an integer it won't add anything to it, if you pass it a floating point number it will always round up. Andy Quote Link to post Share on other sites
JohnB 255 Posted August 23, 2010 Report Share Posted August 23, 2010 Andy, could you possibly step back once and show me how to do the division? My problem is the same as OP's but I don't know how to divide. What I am doing is getting a total number of records (20 to a page) so I want the number of cycles in the loop to be (#totalrecords divided by 20 +1 (if there is a remainder). Thank you John PS I get the Math.ceil() function, I just want to do the division without showing it on the screen (i.e document.write()). Quote Link to post Share on other sites
JohnB 255 Posted August 23, 2010 Report Share Posted August 23, 2010 Disregard. The math happens inside the Math.ceil() function... All done, working like a champ! Quote Link to post Share on other sites
sgsites 0 Posted January 20, 2011 Report Share Posted January 20, 2011 Net66's attached image is broke. Does anyone know the correct url for the image? I'm having a heck of a time with javascript, and every post I find on this forum with an image or ubot examples of javascript has a broken link associated to it. Anyone that can point me in the direction of newbie javascript-ubot examples (examples that don't have broken links) would be greatly appreciated. Thanks,Steve Quote Link to post Share on other sites
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.