Advertisement
RandomGuy32

chooseActivity()

Mar 1st, 2014
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function chooseActivity() {
  2.             m = 0;
  3.             n = 0;
  4.             commaAmount = 0;
  5.             options = [];
  6.             input = document.getElementById("txtInput").value;
  7.             for (var i = 0; i < input.length; i++) {
  8.                 if (input.charAt(i) == ",") {
  9.                     commaAmount++;
  10.                     }
  11.                 }
  12.             for (var j = 0; j < commaAmount + 1; j++) {
  13.                 options[j] = "";
  14.                 }
  15.             for (n = 0; n < input.length; n++) {
  16.                 if ((input.charAt(n) == ",") && (input.charAt(n + 1) == " ")) {
  17.                     n++;
  18.                     m++;
  19.                     }
  20.                 else {
  21.                     options[m] += input.charAt(n);
  22.                     }
  23.                 }
  24.             output = options[Math.floor(Math.random() * options.length)];
  25.             document.getElementById("divOutput").innerHTML = output;
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement