[Web4lib] CGI Forms: checkboxes and stringing of multiple fields

Thomas Bennett bennetttm at appstate.edu
Mon Dec 10 17:41:10 EST 2007


I'm not sure about other servers but on mine if a checkbox is not checked then 
nothing is sent to be processed. This means if the checkbox is checked my 
server receives the variable and the value, if not checked then nothing.  So 
if this is the common case, you would first have to see if the name 
"checkbox" exits as a variable and then get the value or your script could 
have a default value based on the variable name since it exists or it doesn't 
exist.  

I am using zope which you can download free and setup a page with just 
"<dtml-var REQUEST>", set that page as your form action, and it will show you 
all of the form data that is passed among other http environment variables.

Thomas

On Monday 10 December 2007 13:37, Baker, Tammy K wrote:
> Greetings everyone,
>
> I'm working on interlibrary loan request forms and I'm seeking some
> insight since I'm really rusty and not much of a programmer. First, it
> was decided that phone numbers would be in separate fields rather than
> one field; so we went from this:
>
> Phone# <input name="Phone" type="text" size="13">
>
> to this:
>
> Phone# (
>
> <input name="AreaCode" type="text" size="3">
>
> )
>
> <input name="Prefix" type="text" size="3">
>
> -
>
> <input name="Number" type="text" size="4">
>
> The part of the cgi script pertaining to the phone number had
>
> print MESSAGE "Phone#: $FORM{Phone}\n";
>
> Now I have to string three fields together and wanted to know if the
> following would work (to display something like 832-555-1212):
>
> print MESSAGE "Phone#: $FORM{AreaCode}-$FORM{Prefix}-$FORM{Number}\n";
>
> Second, I have never seen information on how checkboxes are treated with
> cgi. For example, the following on the form:
>
> Did you check the library catalog to determine whether the item is
> available locally? <input type="checkbox" name="checkbox"
> value="checkbox">
>
> I'm not sure how to get the results of the checkbox from the webform to
> the email recipient. I'm probably way off but would something like the
> following work:
>
> if ($FORM{ckeckbox} = "yes") {
>
> print MESSAGE "I checked the library catalog before submitting.\n";
>
> }
>
> else {
>
> print MESSAGE "I did not check the library catalog before
> submitting.\n";
>
> }
>
> Thank you so much in advance for any insight.
>
> Sincerely,
>
> Tammy K. Baker, Technology Librarian
> Automated Library Services
> District Services and Training Center
> North Harris Montgomery Community College District
> 5000 Research Forest Drive
> The Woodlands, Texas 77381-4356 USA
>
> Telephone:            (832) 813-6652
> Facsimile:              (832) 813-6614
> Electronic mail:      tammy.k.baker at nhmccd.edu
> <mailto:tammy.k.baker at nhmccd.edu>
>
> NHMCCD is becoming
> Lone Star College System
>
> _______________________________________________
> Web4lib mailing list
> Web4lib at webjunction.org
> http://lists.webjunction.org/web4lib/

-- 
====================================================================
Thomas McMillan Grant Bennett		Appalachian State University
Operations & Systems Analyst		P O Box 32026
University Library				Boone, North Carolina 28608
(828) 262 6587

They say a picture is worth a thousand words.  As videos could be 25 pictures 
per second and might last several minutes, how many words is that? 
- Linux Journal, July 2007

Library Systems Help Desk: http://www.library.appstate.edu/help/
====================================================================


More information about the Web4lib mailing list