Hi I have the following script which should generate 3 unique random numbers and store them in the corresponding text boxes when run but it returns an error.
<script>
function addLuckyDip(lineNumber) {
var randomnumber[0] = Math.floor(Math.random() * maxValue) + 1;
var randomnumber[1] = randomnumber[0];
var randomnumber[2] = randomnumber[0];
while(randomnumber[1] == randomnumber[0]) {
randomnumber[1] = Math.floor(Math.random() * maxValue) + 1;
}
while(randomnumber[2] == randomnumber[0] || randomnumber[2] == randomnumber[1]) {
randomnumber[2] = Math.floor(Math.random() * maxValue) + 1;
}
for(var i = 0; i < 3; i++) {
document.lotteryPlayslipForm.elements["drawGameBoards["+lineNumber+"][numbersChosen]["+i+"]"].value = randomnumber;
}
}
</script>
<form name="lotteryPlayslipForm">
<input type="text" name="drawGameBoards[0][numbersChosen][0]" class="text">
<input type="text" name="drawGameBoards[0][numbersChosen][1]" class="text">
<input type="text" name="drawGameBoards[0][numbersChosen][2]" class="text">
</form>
<script>
function addLuckyDip(lineNumber) {
var randomnumber[0] = Math.floor(Math.random() * maxValue) + 1;
var randomnumber[1] = randomnumber[0];
var randomnumber[2] = randomnumber[0];
while(randomnumber[1] == randomnumber[0]) {
randomnumber[1] = Math.floor(Math.random() * maxValue) + 1;
}
while(randomnumber[2] == randomnumber[0] || randomnumber[2] == randomnumber[1]) {
randomnumber[2] = Math.floor(Math.random() * maxValue) + 1;
}
for(var i = 0; i < 3; i++) {
document.lotteryPlayslipForm.elements["drawGameBoards["+lineNumber+"][numbersChosen]["+i+"]"].value = randomnumber;
}
}
</script>
<form name="lotteryPlayslipForm">
<input type="text" name="drawGameBoards[0][numbersChosen][0]" class="text">
<input type="text" name="drawGameBoards[0][numbersChosen][1]" class="text">
<input type="text" name="drawGameBoards[0][numbersChosen][2]" class="text">
</form>