In this lesson you will have a recipe table with simple calculation in your website
At the least of this lesson, you should have:
Say hello to the user via an alert box and show their name in your web page. Take a look at Java Script Method and properties. And get start to creat your own alter box!!
You could improve your recipe table so that it could calculate the quantity of ingredients. For example, if you want make 3 omelette, and you enter 3 as the amount of omelette, then amount of egg and salt you need will be shown in the last column your quantity box.
<script>
function get_quantity() {
var quantity = +document.recipe.quantity.value;
var numberofegg = 0;
var amountofsalt = 0;
var eggPerOmelette = 2;
var saltPerOmelette = 50;
numberofegg = quantity * eggPerOmelette;
amountofsalt = quantity * saltPerOmelette;
document.getElementById('numberofegg').value = numberofegg;
document.getElementById('amountofsalt').value = amountofsalt;
}
</script>
You will also need to include three input form in your table. Here is an example of the input form for showing the amount of ingredients you need:
<td colspan="2"><input type="text" name="amountofsalt" id="amountofsalt" readonly="readonly" maxlength="100"/></td>
(Bcakground picture Source from: Love Wallpaper HD)