Example of the random quote generator:

To show a random quote from html quote list..

1. Find a quote list (example: quotes).
2. In the quote list, how is each quote separated? comma? crlf? br tag?
3. Use $.get to get the content of the quote list (line 1).
4. Within the function, split the data into an array on the quote separation characters to create an array of quotes (line 2).
5. Return a random number within the length of the array and display the random quote (lines 3 and 4).

1. $.get('../pic/quotes.html', function(data) {
2.     var quotes = data.split("<BR><BR>");
3.     var idx = Math.floor(quotes.length * Math.random());
4.     alert(quotes[idx]);
5. );

Example of random number (1 - 100000000)

Script to generate random number:
1. function randomNumber()
2. {
3.    $("#randomNumberResult").val(
		* 100000000) + 1)));
4. }

Example of random number (1 - 100000000) with random number of digits

Script to generate random number with random number of digits:
1. function randomPLNumber()
2. {
3.     $("#randomPLNumberResult").val(
4. }

Adding the values of a random amount of elements.

Random array of comma-separated numbers:

For the random amounts to add up, I use the following:
1.  function randomArrayResult()
2.  {
3. 	   var arr = $("#arrayvalues").val().split(",");
4.     var total = 0;
5.     $.each(arr,function() 
6. 	   {
7. 		 total += parseInt(this);
8. 	   });
9.     $("#randomArrayResult").val(total);
10. }
Line 3 splits the comma-delimited string into an array of numeric values. Line 5 creates a loop to examine each numeric item in the array of numeric values. Line 7 converts the current item in the array "this" into a number and adds the number to the current value of the variable "total". Line 9 displays the result by setting the label "randomArrayResult" to the result.

Copyright © Oproot Research. All rights reserved.
Permission is granted for limited, non-commercial use of text and images. If used, please credit and notify Oproot Research. If circumstances permit, please include the URL: //oproot.com. Oproot Research would appreciate a copy of publication. High-resolution images are also available. Please email requests, comments to tech@oproot.com.



  P.O. Box 235
  Hondo TX 78861
  email: code@oproot.com