Q. How to make a billing machine which gives out the bill of the items you have ordered?
<head>
<script>
var m;
function pick(F1)
{
var z=" "
for(j=0;j<3;j++)
{
for(i=0;i<F1.elements[j].length;i++)
{
if(F1.elements[j][i].selected)
{
var y=F1.elements[j].options[i].value;
z=z+ "\n" +y;
F1.elements[3].value=z;
}
}
}
m=z;
}
function total(F1)
{
var d=0;
for(j=0;j<3;j++)
{
for(i=0;i<F1.elements[j].length;i++)
{
if(F1.elements[j][i].selected)
{
var y=F1.elements[j].options[i].value;
s=new String(y);
var a=s.indexOf(">");
var b=s.substring(a+2,a+4);
c=parseInt(b);
d=d+c;
}
}
}
p="Total cost of the selected items= "+d;
m=m+ "\n" + p;
F1.elements[3].value=m;
}
function clr(F1)
{
F1.elements[3].value=" "
}
</script>
</head>
<body>
<h1><font color=blue>Welcome to the World Famous Fast Food Center</font><font color=red> Buffet!</font></h1>
<h3>Select the Menu Items of your choice:</h3>
<form name="F1">
<table border=0>
<tr><th>
Major Dishes :<br>
<select multiple onBlur="pick(this.form)">
<option value="Mc Burger --> 40" >Mc Burger</option>
<option value="Fish Fillets --> 70" >Fish Fillets</option>
<option value="Chicken Burger --> 50">Chicken Burger</option>
<option value="Veg. Burger --> 25">Veg. Burger</option>
</select multiple></td>
<th>Starters :<br>
<select multiple onBlur="pick(this.form)">
<option value="French Fries --> 35" >French Fries</option>
<option value="Nuggets --> 60">Nuggets</option>
<option value="Hash Browns --> 80">Hash Browns</option>
<option value="Mc Aloo Tikki --> 25">Mc Aloo Tikki</option>
</select multiple>
</td>
<th valign=top>
Miscellaneous : <br><select onBlur="pick(this.form)">
<option>Choose your drink</option>
<option value="Soft drink --> 30">Soft drink</option>
<option value="Milkshake --> 40">Milkshake</option>
<option value="Softy --> 30">Softy</option>
</select></td></tr>
<tr>
<th colspan=3>
The items selected from the menu are:<br>
<textArea cols="35" rows="15"></TextArea><br><br>
<input type=button value="Total Cost" onClick=total(this.form)>  
<input type=reset value="Clear"></center></td>
</body>
</html>
No comments:
Post a Comment