/    Sign up×
Community /Pin to ProfileBookmark

html pizzo ordering using JavaScript

I need to finish several assignments before Monday (You’re allowed to use any means nessesary so I’m not cheatin) and I can’t get this one to work.

The idea is that users can select several toppings before clicking ‘Bak mijn Pizza'(Bake my pizza), the program should than open a window contain a table with what they’ve ordered, a ‘bestel'(order) button an a ‘herstel'(reset button). After clicking ‘herstel’ users should see an alert saying their pizza wil be delivered within 15 minutes.

This is what I came up with: (this obvl. doesn’t work yet, please help me!)

[I]<!DOCTYPE html>
<html lang=”nl”>
<head>
<meta charset=”utf-8″>
<title>PO van Marleen Peeters</title>
<script language=”Javascript”>
function bestel(){<!–Deze functie opend een pop-up en sluit daarna het venster af–>
alert(“Uw pizza is besteld en wordt binnen 15 minuten warm afgeleverd!”);
myWin.close();
}
function resultaat(form1){
var windowFeatures=’width=400,height=400,scrollbar=no,status=no,tootbar=no’;
var string1='<table-border=1>’;
for(i=0;1<form1.pizza.length;i++){
if(form1.pizza[i].checked)
string1+='<tr><td>’ + form1.pizza[i].value + ‘</td><td width =”60” align=”right”>’+
eval(‘form1.bedrag[‘+i+i’].value’)+'</td></tr>’;}
else {
string1+=”;}
totaal=0
for (i=0;i<from1.pizza.length;i++) {
if (form1.pizza[i].checked){
if (form1.pizza[i].checked){
totaal+=parseFloat(form1.bedrag[i].value);}
eindbedrag=(Math.round(totaal*100)/100);}}
string2='<tr><td><b>Totaal:</b></td><td align=”right”><b>’ + eindbedrag + ‘</b></td></tr></table>’;

myWin=open(”,”, windowFeatures);
myWin.document.open();
myWin.document.write(‘<html><head><title> Pizzeria Staccatio </title></head><body>’);
myWin.document.write(‘<div> align=”center”><h3> U bestelde de volgende pizza :></h3>Basis plus:’);
myWin.document.write(string1);
myWin.document.write(string2);
myWin.document.write(‘<br><br><form><imput type=”button” value=”bestel” onclick=”open.bestel()”>’);
myWin.document.write(‘&nbsp<input type=”button” value=”herstel” onclick=”Self.close()”><hr width=”75%”>’);
myWin.document.write(‘</form></div></body></html>’);
myWin.document.close();}

</script>
</head>
<body>
<h2>Stel Uw eigen smulpizza samen!</h2>
<b>Basis plus de volgende extra ingredienten:<br></b>
<form name=”form1″>
<table>
<tr>
<td><input type=”checkbox” value=”tomaat” name=”pizza”>Tomaat</td>
<td>€ <input type=”text” value=”2.95″ name=”bedrag” onFocus=”blur()” size=5></td>
</tr>
<tr>
<td><input type=”checkbox” value=”Parmazaanse kaas” name=”pizza”>Parmazaanse kaas</td>
<td>€ <input type=”text” value=”2.00″ name=”bedrag” onFocus=”blur()” size=5></td>
</tr>
<tr>
<td><input type=”checkbox” value=”Gorgonzola” name=”pizza”>Gorgonzola</td>
<td>€ <input type=”text” value=”1.95″ name=”bedrag” onFocus=”blur()” size=5></td>
</tr>
<tr>
<td><input type=”checkbox” value=”Olijven” name=”pizza”>Olijven</td>
<td>€ <input type=”text” value=”2.50″ name=”bedrag” onFocus=”blur()” size=5></td>
</tr>
<tr>
<td><input type=”checkbox” value=”Ansjovis” name=”pizza”>Ansjovis</td>
<td>€ <input type=”text” value=”3.00″ name=”bedrag” onFocus=”blur()” size=5></td>
</tr>
<tr>
<td><input type=”checkbox” value=”Aardbeien” name=”pizza”>Aardbeien</td> <!–Op de pizza!?–>
<td>€ <input type=”text” value=”2.00″ name=”bedrag” onFocus=”blur()” size=5></td>
</tr>
<tr>
<td><input type=”checkbox” value=”Broccoli” name=”pizza”>Broccoli</td>
<td>€ <input type=”text” value=”1.99″ name=”bedrag” onFocus=”blur()” size=5></td>
</tr>
<tr>
<td><input type=”checkbox” value=”Asperges” name=”pizza”>Asperges</td>
<td>€ <input type=”text” value=”4.00″ name=”bedrag” onFocus=”blur()” size=5></td>
</tr>
<tr>
<td><input type=”checkbox” value=”Rode peper” name=”pizza”>Rode peper</td>
<td>€ <input type=”text” value=”1.00″ name=”bedrag” onFocus=”blur()” size=5></td>
</tr>
<tr>
<td><input type=”checkbox” value=”Groene peper” name=”pizza”>Groene peper</td>
<td>€ <input type=”text” value=”1.50″ name=”bedrag” onFocus=”blur()” size=5></td>
</tr>
<br>
<br>
<input type=”button” value=”Bak mijn pizza!” onClick=”resultaat(this.form)”>
<input type=”reset” value=”herstel”>
</form>
</body>
</html>
[/I]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERNov 22.2015 — One mistake:
[code=php]
for(i=0;1<form1.pizza.length;i++){
[/code]

You cannot loop with a constant as your test.

You should also use the error console to see the errors as they occur.
×

Success!

Help @StillAttempting spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...