Database Reference
In-Depth Information
"cow_order"
,
"accessories"
);
my
@acc_val
=
defined
(
$accessories
)
?
split
(
/,/
,
$accessories
)
: ();
print
br
(),
"Cow accessory items:"
,
br
();
print
checkbox_group
(
-
name
=>
"accessories"
,
-
values
=>
$acc_info
->
{
values
},
-
default
=>
\
@acc_val
,
-
override
=>
1
,
-
linebreak
=>
1
);
5. Create the customer information fields. These are text input fields, except the state,
shown here as a single-pick scrolling list:
print
br
(),
"Customer name:"
,
br
();
print
textfield
(
-
name
=>
"cust_name"
,
-
value
=>
$cust_name
,
-
override
=>
1
,
-
size
=>
60
);
print
br
(),
"Customer street address:"
,
br
();
print
textfield
(
-
name
=>
"cust_street"
,
-
value
=>
$cust_street
,
-
override
=>
1
,
-
size
=>
60
);
print
br
(),
"Customer city:"
,
br
();
print
textfield
(
-
name
=>
"cust_city"
,
-
value
=>
$cust_city
,
-
override
=>
1
,
-
size
=>
60
);
my
@state_values
;
my
%state_labels
;
my
$sth
=
$dbh
->
prepare
(
qq{
SELECT abbrev, name FROM states ORDER BY name
}
);
$sth
->
execute
();
while
(
my
(
$abbrev
,
$name
)
=
$sth
->
fetchrow_array
())
{
push
(
@state_values
,
$abbrev
);
# save each value in an array
$state_labels
{
$abbrev
}
=
$name
;
# map each value to its label
}
print
br
(),
"Customer state:"
,
br
();
print
scrolling_list
(
-
name
=>
"cust_state"
,
-
values
=>
\
@state_values
,
-
labels
=>
\
%state_labels
,
-
default
=>
$cust_state
,
-
override
=>
1
,
-
size
=>
6
);
# display 6 items at a time