Database Reference
In-Depth Information
SELECT
color, size, accessories,
cust_name, cust_street, cust_city, cust_state
FROM cow_order WHERE id = ?
} , undef , $id );
2. Begin the form:
print start_form ( - action => url ());
3. Generate the hidden field containing the id value that uniquely identifies the
cow_order record:
print hidden ( - name => "id" , - value => $id , - override => 1 );
The override argument forces CGI.pm to use the value specified in the value
argument as the hidden field value. If override is not true, CGI.pm normally tries
to use values present in the script execution environment to initialize form fields,
even if you provide values in the field-generating calls. (CGI.pm does this to make
it easier to redisplay a form with the values the user just submitted. For example, if
you find that a form has been filled in incorrectly, you can redisplay it and ask the
user to correct any problems. To make sure that a form element contains the value
you specify, it's necessary to override this behavior.)
4. Create the fields that describe the cow figurine specifications. Generate these fields
the same way as described in Recipes 20.2 and 20.3 , except set the default values
from the contents of record 1. The code here presents color as a pop-up menu,
size as a set of radio buttons, and accessories as a set of checkboxes. Note that it
splits the accessories value at commas to produce an array of values because the
column value might name several accessory items:
my $color_ref = $dbh -> selectcol_arrayref ( qq{
SELECT color FROM cow_color ORDER BY color
} );
print br (), "Cow color:" , br ();
print popup_menu ( - name => "color" ,
- values => $color_ref ,
- default => $color ,
- override => 1 );
my $size_info = get_enumorset_info ( $dbh , "cookbook" ,
"cow_order" , "size" );
print br (), "Cow figurine size:" , br ();
print radio_group ( - name => "size" ,
- values => $size_info -> { values },
- default => $size ,
- override => 1 ,
- linebreak => 1 );
my $acc_info = get_enumorset_info ( $dbh , "cookbook" ,
Search WWH ::




Custom Search