Javascript parsing error token(details are as follows)
up vote
0
down vote
favorite
document.getElementById("button").onclick = function(){myFunction();
function myFunction() {
var random = Math.floor((Math.random() * 78) + 1);
document.getElementById("demo").innerHTML = random;
} // error is stated here
<!DOCTYPE html>
<html>
<head>
<script type = "text/javascript" src = "script.js"></script>
<link rel= "stylesheet" type = "text/css" href ="mystyle.css">
</head>
<body>
<Table>
<tr>
<td class = "bingocell" id = 1>1</td>
<td class = "bingocell" id = 2>2</td>
<td class = "bingocell" id = 3>3</td>
<td class = "bingocell" id = 4>4</td>
<td class = "bingocell" id = 5>5</td>
</tr>
<tr>
<td class = "bingocell" id = 6>1</td>
<td class = "bingocell" id = 7>2</td>
<td class = "bingocell" id = 8>3</td>
<td class = "bingocell" id = 9>4</td>
<td class = "bingocell" id = 10>5</td>
</tr>
<tr>
<td class = "bingocell" id = 11>1</td>
<td class = "bingocell" id = 12>2</td>
<td class = "bingocell" id = 13>3</td>
<td class = "bingocell" id = 14>4</td>
<td class = "bingocell" id = 15>5</td>
</tr>
<tr>
<td class = "bingocell" id = 16>1</td>
<td class = "bingocell" id = 17>2</td>
<td class = "bingocell" id = 18>3</td>
<td class = "bingocell" id = 19>4</td>
<td class = "bingocell" id = 20>5</td>
</tr>
<tr>
<td class = "bingocell" id = 21>1</td>
<td class = "bingocell" id = 22>2</td>
<td class = "bingocell" id = 23>3</td>
<td class = "bingocell" id = 24>4</td>
<td class = "bingocell" id = 25>5</td>
</tr>
</Table>
<p>Click the button to display a random number between 1 and 78.</p>
<button id = "button" onclick = "myFunction()">Try it</button>
<p id="demo"></p>
</body>
</html>
Errors:
ERROR: 'document' is not defined. [no-undef] document.getElementById("button").onclick = function(){myFunction()};
4
ERROR: 'x' is assigned a value but never used. [no-unused-vars] var x = document.getElementById("demo");
4
ERROR: 'document' is not defined. [no-undef] var x = document.getElementById("demo");
6
ERROR: 'document' is not defined. [no-undef] document.getElementById("demo").innerHTML = random
Things to note:
-File location of JS and CSS are in the exam same folder.
-I never really learnt to write external JS so I don't understand differences between internal and external but what works internally doesn't seem to work externally and it's very frustrating.
javascript
add a comment |
up vote
0
down vote
favorite
document.getElementById("button").onclick = function(){myFunction();
function myFunction() {
var random = Math.floor((Math.random() * 78) + 1);
document.getElementById("demo").innerHTML = random;
} // error is stated here
<!DOCTYPE html>
<html>
<head>
<script type = "text/javascript" src = "script.js"></script>
<link rel= "stylesheet" type = "text/css" href ="mystyle.css">
</head>
<body>
<Table>
<tr>
<td class = "bingocell" id = 1>1</td>
<td class = "bingocell" id = 2>2</td>
<td class = "bingocell" id = 3>3</td>
<td class = "bingocell" id = 4>4</td>
<td class = "bingocell" id = 5>5</td>
</tr>
<tr>
<td class = "bingocell" id = 6>1</td>
<td class = "bingocell" id = 7>2</td>
<td class = "bingocell" id = 8>3</td>
<td class = "bingocell" id = 9>4</td>
<td class = "bingocell" id = 10>5</td>
</tr>
<tr>
<td class = "bingocell" id = 11>1</td>
<td class = "bingocell" id = 12>2</td>
<td class = "bingocell" id = 13>3</td>
<td class = "bingocell" id = 14>4</td>
<td class = "bingocell" id = 15>5</td>
</tr>
<tr>
<td class = "bingocell" id = 16>1</td>
<td class = "bingocell" id = 17>2</td>
<td class = "bingocell" id = 18>3</td>
<td class = "bingocell" id = 19>4</td>
<td class = "bingocell" id = 20>5</td>
</tr>
<tr>
<td class = "bingocell" id = 21>1</td>
<td class = "bingocell" id = 22>2</td>
<td class = "bingocell" id = 23>3</td>
<td class = "bingocell" id = 24>4</td>
<td class = "bingocell" id = 25>5</td>
</tr>
</Table>
<p>Click the button to display a random number between 1 and 78.</p>
<button id = "button" onclick = "myFunction()">Try it</button>
<p id="demo"></p>
</body>
</html>
Errors:
ERROR: 'document' is not defined. [no-undef] document.getElementById("button").onclick = function(){myFunction()};
4
ERROR: 'x' is assigned a value but never used. [no-unused-vars] var x = document.getElementById("demo");
4
ERROR: 'document' is not defined. [no-undef] var x = document.getElementById("demo");
6
ERROR: 'document' is not defined. [no-undef] document.getElementById("demo").innerHTML = random
Things to note:
-File location of JS and CSS are in the exam same folder.
-I never really learnt to write external JS so I don't understand differences between internal and external but what works internally doesn't seem to work externally and it's very frustrating.
javascript
Welcome to StackOverflow! Can you also provide the HTML for the code, and also more details regarding the exact error message?
– Andreas
Nov 8 at 4:02
}
is missing at the end offunction(){myFunction();
– rv7
Nov 8 at 4:03
Edit your question to add the HTML, don't add it in a comment.
– RobG
Nov 8 at 4:24
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
document.getElementById("button").onclick = function(){myFunction();
function myFunction() {
var random = Math.floor((Math.random() * 78) + 1);
document.getElementById("demo").innerHTML = random;
} // error is stated here
<!DOCTYPE html>
<html>
<head>
<script type = "text/javascript" src = "script.js"></script>
<link rel= "stylesheet" type = "text/css" href ="mystyle.css">
</head>
<body>
<Table>
<tr>
<td class = "bingocell" id = 1>1</td>
<td class = "bingocell" id = 2>2</td>
<td class = "bingocell" id = 3>3</td>
<td class = "bingocell" id = 4>4</td>
<td class = "bingocell" id = 5>5</td>
</tr>
<tr>
<td class = "bingocell" id = 6>1</td>
<td class = "bingocell" id = 7>2</td>
<td class = "bingocell" id = 8>3</td>
<td class = "bingocell" id = 9>4</td>
<td class = "bingocell" id = 10>5</td>
</tr>
<tr>
<td class = "bingocell" id = 11>1</td>
<td class = "bingocell" id = 12>2</td>
<td class = "bingocell" id = 13>3</td>
<td class = "bingocell" id = 14>4</td>
<td class = "bingocell" id = 15>5</td>
</tr>
<tr>
<td class = "bingocell" id = 16>1</td>
<td class = "bingocell" id = 17>2</td>
<td class = "bingocell" id = 18>3</td>
<td class = "bingocell" id = 19>4</td>
<td class = "bingocell" id = 20>5</td>
</tr>
<tr>
<td class = "bingocell" id = 21>1</td>
<td class = "bingocell" id = 22>2</td>
<td class = "bingocell" id = 23>3</td>
<td class = "bingocell" id = 24>4</td>
<td class = "bingocell" id = 25>5</td>
</tr>
</Table>
<p>Click the button to display a random number between 1 and 78.</p>
<button id = "button" onclick = "myFunction()">Try it</button>
<p id="demo"></p>
</body>
</html>
Errors:
ERROR: 'document' is not defined. [no-undef] document.getElementById("button").onclick = function(){myFunction()};
4
ERROR: 'x' is assigned a value but never used. [no-unused-vars] var x = document.getElementById("demo");
4
ERROR: 'document' is not defined. [no-undef] var x = document.getElementById("demo");
6
ERROR: 'document' is not defined. [no-undef] document.getElementById("demo").innerHTML = random
Things to note:
-File location of JS and CSS are in the exam same folder.
-I never really learnt to write external JS so I don't understand differences between internal and external but what works internally doesn't seem to work externally and it's very frustrating.
javascript
document.getElementById("button").onclick = function(){myFunction();
function myFunction() {
var random = Math.floor((Math.random() * 78) + 1);
document.getElementById("demo").innerHTML = random;
} // error is stated here
<!DOCTYPE html>
<html>
<head>
<script type = "text/javascript" src = "script.js"></script>
<link rel= "stylesheet" type = "text/css" href ="mystyle.css">
</head>
<body>
<Table>
<tr>
<td class = "bingocell" id = 1>1</td>
<td class = "bingocell" id = 2>2</td>
<td class = "bingocell" id = 3>3</td>
<td class = "bingocell" id = 4>4</td>
<td class = "bingocell" id = 5>5</td>
</tr>
<tr>
<td class = "bingocell" id = 6>1</td>
<td class = "bingocell" id = 7>2</td>
<td class = "bingocell" id = 8>3</td>
<td class = "bingocell" id = 9>4</td>
<td class = "bingocell" id = 10>5</td>
</tr>
<tr>
<td class = "bingocell" id = 11>1</td>
<td class = "bingocell" id = 12>2</td>
<td class = "bingocell" id = 13>3</td>
<td class = "bingocell" id = 14>4</td>
<td class = "bingocell" id = 15>5</td>
</tr>
<tr>
<td class = "bingocell" id = 16>1</td>
<td class = "bingocell" id = 17>2</td>
<td class = "bingocell" id = 18>3</td>
<td class = "bingocell" id = 19>4</td>
<td class = "bingocell" id = 20>5</td>
</tr>
<tr>
<td class = "bingocell" id = 21>1</td>
<td class = "bingocell" id = 22>2</td>
<td class = "bingocell" id = 23>3</td>
<td class = "bingocell" id = 24>4</td>
<td class = "bingocell" id = 25>5</td>
</tr>
</Table>
<p>Click the button to display a random number between 1 and 78.</p>
<button id = "button" onclick = "myFunction()">Try it</button>
<p id="demo"></p>
</body>
</html>
Errors:
ERROR: 'document' is not defined. [no-undef] document.getElementById("button").onclick = function(){myFunction()};
4
ERROR: 'x' is assigned a value but never used. [no-unused-vars] var x = document.getElementById("demo");
4
ERROR: 'document' is not defined. [no-undef] var x = document.getElementById("demo");
6
ERROR: 'document' is not defined. [no-undef] document.getElementById("demo").innerHTML = random
Things to note:
-File location of JS and CSS are in the exam same folder.
-I never really learnt to write external JS so I don't understand differences between internal and external but what works internally doesn't seem to work externally and it's very frustrating.
document.getElementById("button").onclick = function(){myFunction();
function myFunction() {
var random = Math.floor((Math.random() * 78) + 1);
document.getElementById("demo").innerHTML = random;
} // error is stated here
<!DOCTYPE html>
<html>
<head>
<script type = "text/javascript" src = "script.js"></script>
<link rel= "stylesheet" type = "text/css" href ="mystyle.css">
</head>
<body>
<Table>
<tr>
<td class = "bingocell" id = 1>1</td>
<td class = "bingocell" id = 2>2</td>
<td class = "bingocell" id = 3>3</td>
<td class = "bingocell" id = 4>4</td>
<td class = "bingocell" id = 5>5</td>
</tr>
<tr>
<td class = "bingocell" id = 6>1</td>
<td class = "bingocell" id = 7>2</td>
<td class = "bingocell" id = 8>3</td>
<td class = "bingocell" id = 9>4</td>
<td class = "bingocell" id = 10>5</td>
</tr>
<tr>
<td class = "bingocell" id = 11>1</td>
<td class = "bingocell" id = 12>2</td>
<td class = "bingocell" id = 13>3</td>
<td class = "bingocell" id = 14>4</td>
<td class = "bingocell" id = 15>5</td>
</tr>
<tr>
<td class = "bingocell" id = 16>1</td>
<td class = "bingocell" id = 17>2</td>
<td class = "bingocell" id = 18>3</td>
<td class = "bingocell" id = 19>4</td>
<td class = "bingocell" id = 20>5</td>
</tr>
<tr>
<td class = "bingocell" id = 21>1</td>
<td class = "bingocell" id = 22>2</td>
<td class = "bingocell" id = 23>3</td>
<td class = "bingocell" id = 24>4</td>
<td class = "bingocell" id = 25>5</td>
</tr>
</Table>
<p>Click the button to display a random number between 1 and 78.</p>
<button id = "button" onclick = "myFunction()">Try it</button>
<p id="demo"></p>
</body>
</html>
document.getElementById("button").onclick = function(){myFunction();
function myFunction() {
var random = Math.floor((Math.random() * 78) + 1);
document.getElementById("demo").innerHTML = random;
} // error is stated here
<!DOCTYPE html>
<html>
<head>
<script type = "text/javascript" src = "script.js"></script>
<link rel= "stylesheet" type = "text/css" href ="mystyle.css">
</head>
<body>
<Table>
<tr>
<td class = "bingocell" id = 1>1</td>
<td class = "bingocell" id = 2>2</td>
<td class = "bingocell" id = 3>3</td>
<td class = "bingocell" id = 4>4</td>
<td class = "bingocell" id = 5>5</td>
</tr>
<tr>
<td class = "bingocell" id = 6>1</td>
<td class = "bingocell" id = 7>2</td>
<td class = "bingocell" id = 8>3</td>
<td class = "bingocell" id = 9>4</td>
<td class = "bingocell" id = 10>5</td>
</tr>
<tr>
<td class = "bingocell" id = 11>1</td>
<td class = "bingocell" id = 12>2</td>
<td class = "bingocell" id = 13>3</td>
<td class = "bingocell" id = 14>4</td>
<td class = "bingocell" id = 15>5</td>
</tr>
<tr>
<td class = "bingocell" id = 16>1</td>
<td class = "bingocell" id = 17>2</td>
<td class = "bingocell" id = 18>3</td>
<td class = "bingocell" id = 19>4</td>
<td class = "bingocell" id = 20>5</td>
</tr>
<tr>
<td class = "bingocell" id = 21>1</td>
<td class = "bingocell" id = 22>2</td>
<td class = "bingocell" id = 23>3</td>
<td class = "bingocell" id = 24>4</td>
<td class = "bingocell" id = 25>5</td>
</tr>
</Table>
<p>Click the button to display a random number between 1 and 78.</p>
<button id = "button" onclick = "myFunction()">Try it</button>
<p id="demo"></p>
</body>
</html>
javascript
javascript
edited Nov 8 at 4:31
asked Nov 8 at 4:00
user10493657
12
12
Welcome to StackOverflow! Can you also provide the HTML for the code, and also more details regarding the exact error message?
– Andreas
Nov 8 at 4:02
}
is missing at the end offunction(){myFunction();
– rv7
Nov 8 at 4:03
Edit your question to add the HTML, don't add it in a comment.
– RobG
Nov 8 at 4:24
add a comment |
Welcome to StackOverflow! Can you also provide the HTML for the code, and also more details regarding the exact error message?
– Andreas
Nov 8 at 4:02
}
is missing at the end offunction(){myFunction();
– rv7
Nov 8 at 4:03
Edit your question to add the HTML, don't add it in a comment.
– RobG
Nov 8 at 4:24
Welcome to StackOverflow! Can you also provide the HTML for the code, and also more details regarding the exact error message?
– Andreas
Nov 8 at 4:02
Welcome to StackOverflow! Can you also provide the HTML for the code, and also more details regarding the exact error message?
– Andreas
Nov 8 at 4:02
}
is missing at the end of function(){myFunction();
– rv7
Nov 8 at 4:03
}
is missing at the end of function(){myFunction();
– rv7
Nov 8 at 4:03
Edit your question to add the HTML, don't add it in a comment.
– RobG
Nov 8 at 4:24
Edit your question to add the HTML, don't add it in a comment.
– RobG
Nov 8 at 4:24
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Problem solved
Did 2 things:
1) moved the "
2) This part is a bit embarrassing but I think I should leave it here as a reminder. Copied the JS file, from a JS folder and have only been editing the one still within the JS folder but the one on the same folder has not been edited.
Thanks for the help guys!
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Problem solved
Did 2 things:
1) moved the "
2) This part is a bit embarrassing but I think I should leave it here as a reminder. Copied the JS file, from a JS folder and have only been editing the one still within the JS folder but the one on the same folder has not been edited.
Thanks for the help guys!
add a comment |
up vote
0
down vote
Problem solved
Did 2 things:
1) moved the "
2) This part is a bit embarrassing but I think I should leave it here as a reminder. Copied the JS file, from a JS folder and have only been editing the one still within the JS folder but the one on the same folder has not been edited.
Thanks for the help guys!
add a comment |
up vote
0
down vote
up vote
0
down vote
Problem solved
Did 2 things:
1) moved the "
2) This part is a bit embarrassing but I think I should leave it here as a reminder. Copied the JS file, from a JS folder and have only been editing the one still within the JS folder but the one on the same folder has not been edited.
Thanks for the help guys!
Problem solved
Did 2 things:
1) moved the "
2) This part is a bit embarrassing but I think I should leave it here as a reminder. Copied the JS file, from a JS folder and have only been editing the one still within the JS folder but the one on the same folder has not been edited.
Thanks for the help guys!
answered Nov 8 at 4:43
user10493657
12
12
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53201376%2fjavascript-parsing-error-tokendetails-are-as-follows%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Welcome to StackOverflow! Can you also provide the HTML for the code, and also more details regarding the exact error message?
– Andreas
Nov 8 at 4:02
}
is missing at the end offunction(){myFunction();
– rv7
Nov 8 at 4:03
Edit your question to add the HTML, don't add it in a comment.
– RobG
Nov 8 at 4:24