I'm currently testing some coding for a website I'm hoping to publish in the future which will generate a line of random text when you press a button. I've followed some instructions online on how to write the code however upon testing the button no information is coming through and on opening the javascript file I receive the message:
Script:xxxxx
Line: 4
Char: 1
Error: Expected ']'
Code: 800A03EF
Source: Microsoft JScript compilation error
Here is the relevant javascript:
var Message = [
'message 1'
'message 2'
'message 3'
'message 4'
'message 5'
'message 6'
'message 7'
'message 8'
]
function MessageDisplay() {
var randNum = Math.floor(Math.random() * (Message.length));
document.getElementById('MessageDisplay').innerHTML = Message[randNum];
}
What I'm hoping to see when a button is clicked on the page, is a message saying something like "Message 3". However at the moment I'm getting nothing
Aucun commentaire:
Enregistrer un commentaire