Friday, February 5, 2010

How to process Selection/Radio/Checkbox data in PERL?

This corresponds with the previous post:

For Pull-Down Selection:

if ($form_data{'country'} eq "Australia") {
.
.
.
}


For Radio Selection:

if ($form_data{'type'} eq "orange") {
.
.
.
}


For Checkbox Selection:

if ($form_data{'type'} eq "on") {
.
.
.
}





Please check with the previous posts for the the input/selection HTML. Please also note that you need to have the legendary cgi-lib.pl library called before you can use $form_data{'---'} hash table that captures the query strings from your HTML document.


P.S.: Everything is quite straigtforward except the checkbox query string. If the checkbox is checked, the variable will be sent with a "on" data. Those that are not checked will not be defined at all in PERL.

No comments:

Post a Comment