Skip to content

Instantly share code, notes, and snippets.

@Humoud
Created June 20, 2015 10:40
Show Gist options
  • Save Humoud/e369ee4a30303d1b1149 to your computer and use it in GitHub Desktop.
Save Humoud/e369ee4a30303d1b1149 to your computer and use it in GitHub Desktop.
Web Tutorial 4
<!DOCTYPE HTML>
<html>
<head>
<title>Cafe Pizza</title>
<style>
body{
margin-left: 30px;
}
#el9ora1{
height: 250px;
width: 400px;
}
#el9ora2{
height: 100px;
width: 400px;
}
</style>
</head>
<body>
<h1>Cafe Pizza</h1>
<h3>Coffee and Pizza. Allah!</h3>
<img id="el9ora1" src="pizza-coffee.jpg">
<p>Menu:</p>
<input id="cb1" type="checkbox" value="5"> Turkish Coffee 5KD<br/>
<input id="cb2" type="checkbox" value="10"> Pizza 10KD<br/>
<input id="cb3" type="checkbox" value="7"> Pumpkin Spice Late 7KD<br/>
<img id="el9ora2" src="pizza-coffee.jpg">
<button onclick='order()'>Buy</button>
<script>
function order(){
var orderCost = 0;
var box1 = document.getElementById("cb1");
var box2 = document.getElementById("cb2");
var box3 = document.getElementById("cb3");
if(box1.checked)
orderCost = parseInt(box1.value, 10) + orderCost;
if(box2.checked)
orderCost = parseInt(box2.value, 10) + orderCost;
if(box3.checked)
orderCost = parseInt(box3.value, 10) + orderCost;
alert(orderCost);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment