-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtry.html
More file actions
33 lines (28 loc) · 731 Bytes
/
try.html
File metadata and controls
33 lines (28 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<html>
<body>
<p>How would you like your coffee?</p>
<form>
<input type="radio" name="coffee" value="cream">With cream<br>
<input type="radio" name="coffee" value="sugar">With sugar<br>
<br>
<input type="button" onclick="myFunction()" value="Send order">
<br><br>
<input type="text" id="order" size="50">
<input type="submit" value="Submit">
</form>
<script>
function myFunction() {
var coffee = document.forms[0];
var txt = "";
var i;
for (i = 0; i < coffee.length; i++) {
if (coffee[i].checked) {
txt = txt + coffee[i].value + " ";
}
}
document.getElementById("order").value = "You ordered a coffee with: " + txt;
}
</script>
</body>
</html>