Click to See Complete Forum and Search --> : random generator
graemo
12-09-2002, 11:59 AM
could someone tell me how I can produce a set of 10 randomly generated questions from a selection of 30!!
so that a question is only asked once in each set of 10 questions
all help gratefully accepted!! Please
ahinalu
12-09-2002, 01:58 PM
Graemo
http://www.htmlgoodies.com has a quite few random scripts. Also have you tried http://www.hotscripts.com/JavaScript/Scripts_and_Programs/Randomizing/ ? also, http://js-examples.com/js/ there are quite a few others but I lost the links when someone opened an attachment they shouldn't have :mad:
I hope these links help, they have helped me out of a lot of jams.
Aloha Chris
jeffmott
12-09-2002, 06:33 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>Testing</title>
<script>
var a = new Array();
a[0] = "Question1";
a[1] = "Question2";
a[2] = "Question3";
a[3] = "Question4";
// ...
a[29] = "Question30";
function ques()
{
return a.splice( parseInt(Math.random() * a.length), 1 );
}
</script>
</head>
<body>
<script>
document.write( ques() );
</script>
</body>
</html>