174
Chapter 3
var status = getText(coffeemakerStatusDiv1);
if (status == “Idle”) {
replaceText(coffeemakerStatusDiv1,
“Brewing “ + name + “’s “ +
size + “ “ + beverage);
document.forms[0].reset();
var url = “coffeemaker.php?name=” + escape(name) +
“&size=” + escape(size) +
“&beverage=” + escape(beverage) +
“&coffeemaker=1”;
sendRequest(url);
} else {
var coffeemakerStatusDiv2 =
document.getElementById(“coffeemaker2-status”);
status = getText(coffeemakerStatusDiv2);
if (status == “Idle”) {
replaceText(coffeemakerStatusDiv2,
“Brewing “ + name + “’s “ +
size + “ “ + beverage);
document.forms[0].reset();
var url = “coffeemaker.php?name=” + escape(name) +
“&size=” + escape(size) +
“&beverage=” + escape(beverage) +
“&coffeemaker=2”;
JavaScript
PHP script
HTML form
I think it’s confusing to have an
order brewing, and have the details
of that order still showing on the
order form. Can’t we clear the form
when an order is placed?
Let’s clear the form when an order is placed
Right now, your ofcemates enter their coffee order and click “Order
Coffee”. The coffee order is sent to a coffee maker, and brewing begins.
But the order is still shown on the screen, and co-workers could be
a little confused by that order still being on the screen. It would be a
lot easier if once an order got sent to a coffee maker ...