I get error“document not defined”,and my code doesnt work even if i checked it a lot of times
I am working on a tips calculator, I checked everything and I didn't find any problem, it doesn't calculate...,
and the only error I get is "document not defined".
this is the code for the html`
<body>
<div class="container">
<h1>Tips calculator</h1>
<div id="calculator">
<form>
<p>cat a fost nota dre plata?</p>
<input id="billamt" type="text" placeholder="valoarea notei">RON
<p>cum a fost servirea?</p>
<select id="serviceQual">
<option disabled selected value="0"> --alege o optiune</option>
<option value = "0.3">30% superb</option>
<option value ="0.2">20% satisfacator</option>
<option value = "0.15">15%ok</option>
<option value="0.10">10% nemultumit</option>
<option value = "0.05">5% nasol</option>
</select>
</form>
<p>cate persoane impart nota de plata</p>
<input id="peopleamt" type="text " placeholder="Numarul de persoane">persoane<br>
<button type="button" id="calculate">calculeaza!</button>
</div>
<div id="totalTip"><br>
<span id="tip">0.00</span> <sup>RON</sup>
<small id="each">de persoane</small>
</div>
</div>
<script src="calculate.js"></script>
</body>`
and this for the javascript
`function calculateTip(){
var billAmt = document.getElementById("billamt").value;
var serviceQual = document.getElementById("serviceQual").value;
var numberOfPerson = document.getElementById("peopleamt").value;
if (billAmt === "" || serviceQual ==0) {
alert("va rugam adaugati o valoare");
return;
}
if(numberOfPerson === "" || numberOfPerson <=1){
numberOfPerson=1;
document.getElementById("each").style.display = "none";
}else{
document.getElementById("each").style.display = "block";
}
var total = (billAmt * serviceQual) / numberOfPerson;
total = Math.round(total * 100)/100;
total = total.toFixed(2);
document.getElementById("totalTip").style.display = "block";
document.getElementById("tip").innerHTML = total;
}
document.getElementById("totalTip").style.display = "none";
document.getElementById("each").style.display = "none";
document.getElementById("calculate").onClick = function(){
calculateTip();
}
`
and I have added the javascript file before /body
javascript html5
add a comment |
I am working on a tips calculator, I checked everything and I didn't find any problem, it doesn't calculate...,
and the only error I get is "document not defined".
this is the code for the html`
<body>
<div class="container">
<h1>Tips calculator</h1>
<div id="calculator">
<form>
<p>cat a fost nota dre plata?</p>
<input id="billamt" type="text" placeholder="valoarea notei">RON
<p>cum a fost servirea?</p>
<select id="serviceQual">
<option disabled selected value="0"> --alege o optiune</option>
<option value = "0.3">30% superb</option>
<option value ="0.2">20% satisfacator</option>
<option value = "0.15">15%ok</option>
<option value="0.10">10% nemultumit</option>
<option value = "0.05">5% nasol</option>
</select>
</form>
<p>cate persoane impart nota de plata</p>
<input id="peopleamt" type="text " placeholder="Numarul de persoane">persoane<br>
<button type="button" id="calculate">calculeaza!</button>
</div>
<div id="totalTip"><br>
<span id="tip">0.00</span> <sup>RON</sup>
<small id="each">de persoane</small>
</div>
</div>
<script src="calculate.js"></script>
</body>`
and this for the javascript
`function calculateTip(){
var billAmt = document.getElementById("billamt").value;
var serviceQual = document.getElementById("serviceQual").value;
var numberOfPerson = document.getElementById("peopleamt").value;
if (billAmt === "" || serviceQual ==0) {
alert("va rugam adaugati o valoare");
return;
}
if(numberOfPerson === "" || numberOfPerson <=1){
numberOfPerson=1;
document.getElementById("each").style.display = "none";
}else{
document.getElementById("each").style.display = "block";
}
var total = (billAmt * serviceQual) / numberOfPerson;
total = Math.round(total * 100)/100;
total = total.toFixed(2);
document.getElementById("totalTip").style.display = "block";
document.getElementById("tip").innerHTML = total;
}
document.getElementById("totalTip").style.display = "none";
document.getElementById("each").style.display = "none";
document.getElementById("calculate").onClick = function(){
calculateTip();
}
`
and I have added the javascript file before /body
javascript html5
add a comment |
I am working on a tips calculator, I checked everything and I didn't find any problem, it doesn't calculate...,
and the only error I get is "document not defined".
this is the code for the html`
<body>
<div class="container">
<h1>Tips calculator</h1>
<div id="calculator">
<form>
<p>cat a fost nota dre plata?</p>
<input id="billamt" type="text" placeholder="valoarea notei">RON
<p>cum a fost servirea?</p>
<select id="serviceQual">
<option disabled selected value="0"> --alege o optiune</option>
<option value = "0.3">30% superb</option>
<option value ="0.2">20% satisfacator</option>
<option value = "0.15">15%ok</option>
<option value="0.10">10% nemultumit</option>
<option value = "0.05">5% nasol</option>
</select>
</form>
<p>cate persoane impart nota de plata</p>
<input id="peopleamt" type="text " placeholder="Numarul de persoane">persoane<br>
<button type="button" id="calculate">calculeaza!</button>
</div>
<div id="totalTip"><br>
<span id="tip">0.00</span> <sup>RON</sup>
<small id="each">de persoane</small>
</div>
</div>
<script src="calculate.js"></script>
</body>`
and this for the javascript
`function calculateTip(){
var billAmt = document.getElementById("billamt").value;
var serviceQual = document.getElementById("serviceQual").value;
var numberOfPerson = document.getElementById("peopleamt").value;
if (billAmt === "" || serviceQual ==0) {
alert("va rugam adaugati o valoare");
return;
}
if(numberOfPerson === "" || numberOfPerson <=1){
numberOfPerson=1;
document.getElementById("each").style.display = "none";
}else{
document.getElementById("each").style.display = "block";
}
var total = (billAmt * serviceQual) / numberOfPerson;
total = Math.round(total * 100)/100;
total = total.toFixed(2);
document.getElementById("totalTip").style.display = "block";
document.getElementById("tip").innerHTML = total;
}
document.getElementById("totalTip").style.display = "none";
document.getElementById("each").style.display = "none";
document.getElementById("calculate").onClick = function(){
calculateTip();
}
`
and I have added the javascript file before /body
javascript html5
I am working on a tips calculator, I checked everything and I didn't find any problem, it doesn't calculate...,
and the only error I get is "document not defined".
this is the code for the html`
<body>
<div class="container">
<h1>Tips calculator</h1>
<div id="calculator">
<form>
<p>cat a fost nota dre plata?</p>
<input id="billamt" type="text" placeholder="valoarea notei">RON
<p>cum a fost servirea?</p>
<select id="serviceQual">
<option disabled selected value="0"> --alege o optiune</option>
<option value = "0.3">30% superb</option>
<option value ="0.2">20% satisfacator</option>
<option value = "0.15">15%ok</option>
<option value="0.10">10% nemultumit</option>
<option value = "0.05">5% nasol</option>
</select>
</form>
<p>cate persoane impart nota de plata</p>
<input id="peopleamt" type="text " placeholder="Numarul de persoane">persoane<br>
<button type="button" id="calculate">calculeaza!</button>
</div>
<div id="totalTip"><br>
<span id="tip">0.00</span> <sup>RON</sup>
<small id="each">de persoane</small>
</div>
</div>
<script src="calculate.js"></script>
</body>`
and this for the javascript
`function calculateTip(){
var billAmt = document.getElementById("billamt").value;
var serviceQual = document.getElementById("serviceQual").value;
var numberOfPerson = document.getElementById("peopleamt").value;
if (billAmt === "" || serviceQual ==0) {
alert("va rugam adaugati o valoare");
return;
}
if(numberOfPerson === "" || numberOfPerson <=1){
numberOfPerson=1;
document.getElementById("each").style.display = "none";
}else{
document.getElementById("each").style.display = "block";
}
var total = (billAmt * serviceQual) / numberOfPerson;
total = Math.round(total * 100)/100;
total = total.toFixed(2);
document.getElementById("totalTip").style.display = "block";
document.getElementById("tip").innerHTML = total;
}
document.getElementById("totalTip").style.display = "none";
document.getElementById("each").style.display = "none";
document.getElementById("calculate").onClick = function(){
calculateTip();
}
`
and I have added the javascript file before /body
javascript html5
javascript html5
asked Jan 19 at 13:24
j dowj dow
12
12
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2fsuperuser.com%2fquestions%2f1396070%2fi-get-errordocument-not-defined-and-my-code-doesnt-work-even-if-i-checked-it-a%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f1396070%2fi-get-errordocument-not-defined-and-my-code-doesnt-work-even-if-i-checked-it-a%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