162
Chapter 3
javascript and radio buttons
Getting the beverage and size of the order
Before we gure out how to get and update the status of the two coffee
makers, you need to write the code for getSize() and getBeverage().
Let’s look back at the coffee order form and see what we’re dealing with:
JavaScript
PHP script
HTML form
<form>
<p>Name: <input type=”text” name=”name”
id=”name” /></p>
<h3>Size</h3>
<p>
<input type=”radio” name=”size”
value=”small”
checked=”true”>Small</input>
<input type=”radio” name=”size”
value=”medium”>Medium</input>
<input type=”radio” name=”size”
value=”large”>Large</input>
</p>
<h3>Beverage</h3>
<p>
<input type=”radio” name=”beverage”
value=”mocha”
checked=”true”>Mocha</input>
<input type=”radio” name=”beverage”
value=”latte”>Latte</input>
<input type=”radio” name=”beverage”
value=”cappucino”>Cappucino</input>
</p>
<p>
Here’s coffee.html.
These three <input>s
are the three options
for the beverage.
Here are
the three
size choices.
But how do we find out what size
and beverage Jim selected?