Now I fixed all those errors and this is my new code:
<DOCTYPE html>
<html>
<head>
<title>Javascript- if, else if, else</title>
<meta charset="utf-8">
<meta name="author" content="Sanjin Šincek">
<style type a"text/css">
body {
font-family: verdana;
background-color: #FCF;
}
h1 {
text-align: center;
border-bottom: 2px solid black;
}
form {
width: 40%;
float: left;
}
fieldset {
border: 10px solid #606;
}
p#feedback {
width: 50%;
float: right;
text-align: right;
font-size: 200%;
font-weight: bold;
color: #900;
}
label {
font-size: 16pt;
width: 150px;
display: block;
float: left;
}
input {
width: 50px;
font-size: 16pt;
}
</style>
<script type="text/javascript">
function checkmax3(){
var max3 = document.getElementById('max3').value;
if (max3 =="") {
document.getElementById('feedback').innerHTML = "Upišite broj Max3 paketa!";
return false;
}
age = parseInt(max3);
if (isNaN(max3)) {
document.getElementById('feedback').innerHTML = "Upišite broj!";
return false;
}
else if (max3 = 13) {
document.getElementById('feedback').innerHTML = "4450";
return false;
}
else if (max3 = 14) {
document.getElementById('feedback').innerHTML = "4900";
return false;
}
else if (max3 = 15) {
document.getElementById('feedback').innerHTML = "5350";
return false;
}
} // end of my else statement - user has entered something.
} // end of my checkmax3 function
</script>
</head>
<body>
<h1>Izračun plaća</h1>
<form method="post" action="#" onsubmit="return checkmax3()">
<fieldset>
<label for"max3">Max 3:</label>
<input type="text" id="max3" name="max3">
</fieldset>
<fieldset>
<label for"max2">Max 2:</label>
<input type="text" id="max2" name="max2">
</fieldset>
<fieldset>
<label for"Mobilni">Mobilni:</label>
<input type="text" id="Mobilni" name="Mobilni">
</fieldset>
<input type="submit" value="Potvrdi" style="width: 110px">
</form>
<p id="feedback"></p>
</body>
</html>
My new error is:
×
JavaScript error: SyntaxError: expected expression, got '}' on line 84
I fixed this error finnaly.
My new code:
<DOCTYPE html>
<html>
<head>
<title>Javascript- if, else if, else</title>
<meta charset="utf-8">
<meta name="author" content="Love bitcoin">
<style type a"text/css">
body {
font-family: verdana;
background-color: #FCF;
}
h1 {
text-align: center;
border-bottom: 2px solid black;
}
form {
width: 40%;
float: left;
}
fieldset {
border: 10px solid #606;
}
p#feedback {
width: 50%;
float: right;
text-align: right;
font-size: 200%;
font-weight: bold;
color: #900;
}
label {
font-size: 16pt;
width: 150px;
display: block;
float: left;
}
input {
width: 50px;
font-size: 16pt;
}
</style>
<script type="text/javascript">
function checkmax3(){
var max3 = document.getElementById('max3').value;
if (max3 =="") {
document.getElementById('feedback').innerHTML = "0";
return false;
}
else {
max3 = parseInt(max3);
if (isNaN(max3)) {
document.getElementById('feedback').innerHTML = "Upišite broj";
return false;
}
else if (max3 ==13) {
document.getElementById('feedback').innerHTML = "4450";
return false;
}
else if (max3 ==14) {
document.getElementById('feedback').innerHTML = "4900";
return false;
}
else if (max3 ==15) {
document.getElementById('feedback').innerHTML = "5350";
return false;
}
else if (max3 ==16) {
document.getElementById('feedback').innerHTML = "5800";
return false;
}
else if (max3 ==17) {
document.getElementById('feedback').innerHTML = "6250";
return false;
}
else if (max3 ==18) {
document.getElementById('feedback').innerHTML = "6700";
return false;
}
else if (max3 ==19) {
document.getElementById('feedback').innerHTML = "7150";
return false;
}
else if (max3 ==20) {
document.getElementById('feedback').innerHTML = "7600";
return false;
}
else if (max3 ==21) {
document.getElementById('feedback').innerHTML = "8050";
return false;
}
else if (max3 ==22) {
document.getElementById('feedback').innerHTML = "8500";
return false;
}
else if (max3 ==23) {
document.getElementById('feedback').innerHTML = "8950";
return false;
}
else if (max3 ==24) {
document.getElementById('feedback').innerHTML = "9400";
return false;
}
else if (max3 ==25) {
document.getElementById('feedback').innerHTML = "9850";
return false;
}
else if (max3 ==26) {
document.getElementById('feedback').innerHTML = "10300";
return false;
}
else if (max3 ==27) {
document.getElementById('feedback').innerHTML = "10750";
return false;
}
else if (max3 ==28) {
document.getElementById('feedback').innerHTML = "11200";
return false;
}
else if (max3 ==29) {
document.getElementById('feedback').innerHTML = "11650";
return false;
}
else if (max3 ==30) {
document.getElementById('feedback').innerHTML = "12100";
return false;
}
else if (max3 ==31) {
document.getElementById('feedback').innerHTML = "12550";
return false;
}
else if (max3 ==32) {
document.getElementById('feedback').innerHTML = "13000";
return false;
}
else if (max3 ==33) {
document.getElementById('feedback').innerHTML = "13450";
return false;
}
else if (max3 ==34) {
document.getElementById('feedback').innerHTML = "13900";
return false;
}
else if (max3 ==35) {
document.getElementById('feedback').innerHTML = "14350";
return false;
}
else if (max3 ==36) {
document.getElementById('feedback').innerHTML = "14800";
return false;
}
else if (max3 ==37) {
document.getElementById('feedback').innerHTML = "15250";
return false;
}
else if (max3 ==38) {
document.getElementById('feedback').innerHTML = "15700";
return false;
}
else if (max3 ==39) {
document.getElementById('feedback').innerHTML = "16150";
return false;
}
else if (max3 ==40) {
document.getElementById('feedback').innerHTML = "16600";
return false;
}
else if (max3 ==41) {
document.getElementById('feedback').innerHTML = "17050";
return false;
}
else if (max3 ==42) {
document.getElementById('feedback').innerHTML = "17500";
return false;
}
else if (max3 ==43) {
document.getElementById('feedback').innerHTML = "17950";
return false;
}
else if (max3 ==44) {
document.getElementById('feedback').innerHTML = "18400";
return false;
}
else if (max3 ==45) {
document.getElementById('feedback').innerHTML = "18850";
return false;
}
else if (max3 ==46) {
document.getElementById('feedback').innerHTML = "19300";
return false;
}
else if (max3 ==47) {
document.getElementById('feedback').innerHTML = "19750";
return false;
}
else if (max3 ==48) {
document.getElementById('feedback').innerHTML = "20200";
return false;
}
else if (max3 ==49) {
document.getElementById('feedback').innerHTML = "20650";
return false;
}
else if (max3 ==50) {
document.getElementById('feedback').innerHTML = "21100";
return false;
}
else if (max3 ==51) {
document.getElementById('feedback').innerHTML = "21550";
return false;
}
else if (max3 ==52) {
document.getElementById('feedback').innerHTML = "22000";
return false;
}
else if (max3 ==53) {
document.getElementById('feedback').innerHTML = "22450";
return false;
}
else if (max3 ==54) {
document.getElementById('feedback').innerHTML = "22900";
return false;
}
else if (max3 ==55) {
document.getElementById('feedback').innerHTML = "23350";
return false;
}
else if (max3 ==56) {
document.getElementById('feedback').innerHTML = "23800";
return false;
}
else if (max3 ==57) {
document.getElementById('feedback').innerHTML = "24250";
return false;
}
else if (max3 ==58) {
document.getElementById('feedback').innerHTML = "24700";
return false;
}
else if (max3 ==59) {
document.getElementById('feedback').innerHTML = "25150";
return false;
}
else if (max3 ==60) {
document.getElementById('feedback').innerHTML = "25600";
return false;
}
} // end of my else statement - user has entered something.
} // end of my checkmax3 function
</script>
</head>
<body>
<h1>Izračun plaća</h1>
<form method="post" action="#" onsubmit="return checkmax3()">
<fieldset>
<label for"max3">Max 3:</label>
<input type="text" id="max3" name="max3">
</fieldset>
<fieldset>
<label for"max2">Max 2:</label>
<input type="text" id="max2" name="max2">
</fieldset>
<fieldset>
<label for"Mobilni">Mobilni:</label>
<input type="text" id="Mobilni" name="Mobilni">
</fieldset>
<input type="submit" value="Potvrdi" style="width: 110px">
</form>
<p id="feedback"></p>
</body>
</html>
Idk should I add like this:<form method="post" action="#" onsubmit="return checkmax3()""return checkmax2()"> to add new function or how.I want add 2 more functions and should I first make them to addition themself so it could work or how and which code to put where little but confusing
I want create 2 functions,for 2 fields Max 2 and Mobilni also so I could write number and get result.