Jump to content


JS help


5 replies to this topic

#1 OFFLINE   TheFiresInTheSky

    aka "neighberaaron"

  • Members
  • PipPipPipPip
  • 1,738 posts
  • Gender:Male
  • Location:somewhere in the glove
  • Interests:computers, myspace, website building, skating, ITG, DDR, summers, hanging out at the mall.

Posted 09 April 2006 - 03:09 AM

im trying to make something that would randomely select a number. id like to be able to have a pop-up where you could enter 2 numbers and have it select a random number including those numbers. ive checked websites and asked around but no one knew how to(using JS of course).

#2 OFFLINE   hazelnut

    try to stay calm

  • Moderators
  • 9,458 posts
  • Gender:Female
  • Location:Huddersfield uk

Posted 09 April 2006 - 06:27 PM

I must admit to knowing absolutly nothing about that subject so this link is a pure guess!!

http://www.w3schools...js_obj_math.asp
CCLEANER, RECUVA, DEFRAGGLER AND SPECCY DOCUMENTATION CAN BE FOUND HERE

http://www.piriform.com/docs

#3 OFFLINE   TheFiresInTheSky

    aka "neighberaaron"

  • Members
  • PipPipPipPip
  • 1,738 posts
  • Gender:Male
  • Location:somewhere in the glove
  • Interests:computers, myspace, website building, skating, ITG, DDR, summers, hanging out at the mall.

Posted 09 April 2006 - 09:10 PM

Quote

FROM: lokoike
I found this page:
http://www.w3schools...js_obj_math.asp

It has a bunch of math operators, and it even lets you make and test a page using them.

I was thinking if you wanted to make it choose a number between 0-10, you could use the random function, then multiply your random number by 10, and then round it to a whole number.

For example, random generates: 0.6782433.

Take that x10 and you get 6.782433. Then round it to a whole number and you get 7.


problem: i need all variations of numbers

#4 OFFLINE   lokoike

    Hufu FTW!!!

  • Members
  • PipPipPipPip
  • 1,223 posts
  • Gender:Male
  • Location:Illinois, USA
  • Interests:Hardware / software troubleshooting, open-source / freeware, Popular Mechanics, my g/f, and hufu.

Posted 10 April 2006 - 03:30 AM

View Postneighberaaron, on Apr 9 2006, 04:10 PM, said:


problem: i need all variations of numbers
Hmm... I wish I knew how to code in JS, all I've ever really done is BASIC. I have a suggestion, but I don't know if JS offers the capabilities to do it. Say you want a 4-digit whole number (anywhere from 0-9999):

Use the random function to create a random number, and then multiply it by 10. Then truncate it (as opposed to rounding it) so that the remainder is dropped and you are left with a whole number between 0-9. The reason you truncate instead of round is so that you don't accidently end up with 10 as your number. Hopefully JS has a truncate feature...

Then take that number and save it as a string. Hopefully JS can save numbers as strings...

Then, do the same process three more times, saving each of the numbers as strings, so that JS treats them like text instead of like numbers.

Once you have four 1-digit numbers saved as strings, add all of the strings together to make it one 4 character string. Perhaps you ended up with the numbers 0, 3, 4, and 1. Turn them into strings ("0","3","4", and "1") and add them together ("0341"). Hopefully JS can add the strings that you were hopefully able to make in the first place...

And finally, convert your 4-character string back into a number, in this case 341. Hopefully JS can do that too...

So, needless to say, this suggestion is based totally on the premise that JS contains basic string functions. If it does, that should solve your problem.
Save a tree, eat a beaver.
Save a tree, wipe with an owl.


Every time a bell rings, a thread gets hijacked!
ding, ding!


Give Andavari lots of money and maybe even consider getting K a DVD-RW drive.

If it's not Scottish, IT'S CRAP!!!

#5 OFFLINE   Andavari

    Captain Spectacular

  • Moderators
  • 13,327 posts
  • Gender:Male
  • Location:Shadow Moses

Posted 10 April 2006 - 04:23 PM

There's some sites that offer free scripts, albeit I don't know if they have your specific request. Google 'em to see if they help, you might even find a forum which you could join where people could help you step by step, or at the least give you direction.
Complexity of incoherent design.

#6 OFFLINE   TheFiresInTheSky

    aka "neighberaaron"

  • Members
  • PipPipPipPip
  • 1,738 posts
  • Gender:Male
  • Location:somewhere in the glove
  • Interests:computers, myspace, website building, skating, ITG, DDR, summers, hanging out at the mall.

Posted 14 April 2006 - 08:19 PM

how would i select "random number between 1 and 25? what if i just said like random like links and such advertisements and run it off the internet?