-
Notifications
You must be signed in to change notification settings - Fork 0
/
l7p1.php
executable file
·154 lines (131 loc) · 3.68 KB
/
l7p1.php
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!DOCTYPE html>
<!--
Created by Shade Alabsa
-->
<html>
<head>
<title>Lab 7 Part 1</title>
<meta charset="UTF-8">
<link rel="shortcut icon" href="http://webdev.spsu.edu/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="l2p4.css" />
<script language="Javascript" type="text/javascript">
<!--
//<![CDATA[
function valid() {
var rasp = document.getElementById("rasp").value;
var straw = document.getElementById("straw").value;
var orange = document.getElementById("orange").value;
if(/\D+/.test(rasp)) {
rasp = false;
}
if(/\D+/.test(straw)) {
straw = false;
}
if(/\D+/.test(orange)) {
orange = false;
}
if(rasp == false || straw == false || orange == false) {
var msg = "You entered a non-numeric character for one of the following field or fields:";
if(!rasp) {
msg += " Raspbery,";
}
if(!straw) {
msg += " Strawberry,";
}
if(!orange) {
msg += " Orange,";
}
msg += " please fix this field or fields and resubmit.";
alert(msg);
return false;
}
document.getElementById("form").submit();
}
//]]>
//-->
</script>
</head>
<body>
<h1>Fruit for Sale!</h1>
<h2>Price is based on unit weight</h2>
<form action="http://webdev.spsu.edu/formtest.php" method="post" id="form" onsubmit="return valid();">
<table>
<tr>
<th>Fruit</th>
<th>Price per Pound ($/lb)</th>
<th>Weight</th>
<th>Quantity</th>
</tr>
<tr>
<td>Raspberry</td>
<td>$6.00</td>
<td>1</td>
<td>
<input type="text" name="rasp" id="rasp" size="10" />
</td>
</tr>
<tr>
<td>Garden Strawberry</td>
<td>$5.00</td>
<td>1</td>
<td>
<input type="text" name="straw" id="straw" size="10" />
</td>
</tr>
<tr>
<td>Orange</td>
<td>$2.00</td>
<td>5</td>
<td>
<input type="text" name="orange" id="orange" size="10" />
</td>
</tr>
</table>
<divi class="custInfo">
<label style="display: inline-block;margin-right: 20px;">First Name
<input type="text" id="fname" name="firstName" size="30" />
</label>
<label>Last Name
<input type="text" id="lname" name="lastName" size="30" />
</label>
<br />
<label>Street Address
<input type="text" id="streetAdr" name="streetAddress" size="45" />
</label>
<br />
<label style="display: inline-block;margin-right: 20px;">City
<input type="text" id="city" name="City" size="30" />
</label>
<label style="display: inline-block;margin-right: 20px;">State</label>
<select id="state" name="State">
<?php
$states = array("Alabama", "Florida", "Georgia");
foreach ($states as $state) {
if($state == "Georgia") {
echo '<option value="'.$state.'" selected="selected">'.$state.'</option>';
echo "\n";
} else {
echo '<option value="'.$state.'">'.$state.'</option>';
echo "\n";
}
}
?>
</select>
<label>Zip Code
<input type="text" id="zip" name="zipCode" size="10" />
</label>
<br />
<label>Payment:
<br />
<input type="radio" name="radio" name="payment" value="visa" />Visa
<input type="radio" name="radio" name="payment" value="master" />Mastercard
<input type="radio" name="radio" name="payment" value="discover" />Discover
<input type="radio" name="radio" name="payment" value="amex" />American Express
</label>
<br />
<br />
<input type="submit" value="Submit" />
</div>
</form>
</body>
</html>