I am making an menu list of starbucks the code is working but it only prints:
------
WELCOME TO STARBUCKS
Total Price: "amount"
------
Problem: I want the value to be displayed also in the alert box kinda like anyone help im a noob in js
------
WELCOME TO STARBUCKS
You ordered:
"items here"
Total Price: "amount"
-----
<html>
<head>
<script language="JavaScript">
function tester() {
var a = 0;
var b = 0;
var c = 0;
var d = 0;
var e = 0;
if(document.forms[0].elements[0].checked==true) {
a = 110
}
if(document.forms[0].elements[1].checked==true) {
b = 95
}
if(document.forms[0].elements[2].checked==true) {
c = 110
}
if(document.forms[0].elements[3].checked==true) {
d = 95
}
if(document.forms[0].elements[4].checked==true) {
e = 85
}
total = a + b + c + d + e
{
alert("WELCOME TO STARBUCKS \n Total Price:" + total )
}
}
</script>
</head>
<body>
<center><h1>STARBUCKS</h1></center>
<form method="get" onsubmit="tester()">
<p><input type="checkbox" name="R1" value="Caramel Mochiato">Caramel Mochiato P110</p>
<p><input type="checkbox" name="R1" value="Caffe Latte">Caffe Latte P95</p>
<p><input type="checkbox" name="R1" value="White chocolate mocha">White chocolate mocha P110</p>
<p><input type="checkbox" name="R1" value="Caffe Mocha">Caffe Mocha P95</p>
<p><input type="checkbox" name="R1" value="Caffe Mocha">Cappuccino P85</p>
<div align="center"><p><input type="submit" value="ORDER"></p>
</div>
</form>
</body>
</html>