Witam,
Mam taki problem, że potrzebuję aby po naciścnięciu przycisku na stronie został wylosowany jeden z kilku elementów. Próbowałem wymieszać ze sobą skrypty:
  1. <script type="text/javascript">
  2. Array.prototype.random = function(limit)
  3. {
  4. if (typeof limit == 'undefined' || limit < 0) limit = 1;
  5. else if (!limit) limit = this.length;
  6. for (var i = 0, source = this, target = new Array(), n = source.length; i < limit && n > 0; i++)
  7. {
  8. do { var index = Math.random(); } while (index == 1);
  9. index = Math.floor(index * n);
  10. target.push(source[index]);
  11. source[index] = source[--n];
  12. }
  13. return target;
  14. }
  15.  
  16. document.write(new Array(
  17.  
  18. ).random().join(''));
  19.  
i
  1. <script language="JavaScript">
  2. function pushbutton() {
  3. alert("Hello!");
  4. }
  5. </script>
  6. <input type="button" name="Button1" value="Naciśnij mnie" onclick="pushbutton()">
  7. </form>

jednak to nie poskutkowało. proszę o pomoc