Jump to content
UBot Underground

How to Loop to 1 decimal place


Recommended Posts

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.

 

Thanks

Ninjman.

Link to post
Share on other sites

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.

 

Thanks

Ninjman.

 

You can do this with javascript;

 

post-732-12761595392394_thumb.jpg

 

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

Link to post
Share on other sites
  • 2 months later...

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

Link to post
Share on other sites
  • 4 months later...

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

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...