[ back to toc ]

cgi-perl

Date: 2002/03/14 09:45

Q:
I am having problems with a cgi script that I have to make. Its on
checkboxes. I have to make up a cgi script for a question type sheet.
after they answer the questions by checking the boxes then they will enter
the information.
This is a large project that 7 of us is working on and we all have 2
sections to work out then the enter we want it to save till the end of the
rather long form.

the cgi script and the html script isn't coming up with anything. The html
is going great but it isn't connecting right with the cgi.

Can you help me? I am a new cgi student attending a college for web design
and this is really becoming hard for me to grasp. I guess more classes!

Thank you for your help
Char
A:
Dear Char,

answering your question: yes I can help. Give me specific questions and I
will answer my best.

I doubt that your project is "large". In my reading a project is large
where more than 50 men/women works on and the source code text reaches the
magnitude of 10MByte.

Regards,
Peter

Dear Peter,

Here is the html code that I have to set up the cgi for. Does the NAME
property have to be the same for all the disabilities so that the cgi code
works with them? Can you send me an example of a script that would work
for this? By now you must realize that I am very new at this. I am.
Working so far with cgi hasn't been a real rewarding time. Pretty much
everything that the whole class has used hasn't worked. Thank you for your
time. Could you tell me of maybe a good book to buy to help me on further
cgi scripting. I am going to need this as I am moving on to get my
associates in Web Design.
Thank you again
Char
<html>
<HEAD>
<TITLE>Learning Disabilities Checklist</TITLE>
<LINK REL=stylesheet TYPE="text/css" HREF=dysc.css>
</HEAD>

<body>
<BODY BGCOLOR=YELLOW>
<FORM ACTION="http://crux.baker.edu/c*NAME-DELETED*01/cgi-bin/final23.cgi"
METHOD=POST>
<TABLE>
<TR>
<TD VALIGN=TOP>Historically, the student has<BR>
experienced problems in these areas:
<BR> (Check all that apply.)<BR>
<img src="form.gif" width="38" height="36" hspace="2" vspace="2"
border="0" alt="form image" align="left"></TD>
<TD VALIGN=TOP><INPUT TYPE=CHECKBOX NAME=DISABILITY>Reading Out
Loud<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Understanding what is read<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Remembering what was read<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Spelling<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Forming letters legibly<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Handwriting legibly<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Writing sentences &
paragraphs<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Punctuation<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Grammar<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Following Spoken Diegibly<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>rections<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Remembering what was said<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Understanding what is said<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Remembering schedules<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Planning ahead<BR>
</TD>
<TD VALIGN=TOP>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Meeting deadlines<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Keeping belongings in order<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Sense of direction<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Ordering (ABC's, months...)<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Copying accurately<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Left-Right confusion<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Saying the right thing<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Pronouncing words correctly<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Speaking coherently<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Remembering math facts<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Remembering math processes<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Ability to do mental math<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Forgets math learned<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY>Math anxiety<BR></TD></TR>
<TR>
<TD COLSPAN=3><HR></TD>
</TR>
<TR><TD COLSPAN=3><CENTER><I>Source of the LD Categories below:<BR>
Dr. Larry M. Silver - 1992, Georgetown University, USA</CENTER></I><BR>
</TD></TR>
<TR>

<TD COLSPAN=3> <IMG SRC="inbox.gif" ALIGN=RIGHT><H3><U>INPUT
DISABILITIES</U></H3></TD>
</TR>
<TR>
<TD VALIGN=TOP><P>3 Sets of Input Disabilities:</P><BR><BR></TD>
<TD COLSPAN=2><SELECT NAME=INPUTDISAB SIZE=3>
<OPTION NAME=INPUTDISAB>Visual Perception Disabilities
<OPTION NAME=INPUTDISAB>Auditory Perception Disabilities
<OPTION NAME=INPUTDISAB>Sensory Integration Disabilities
</SELECT></TD>
</TR>

<TR>
<TD VALIGN=TOP><NOBR><img src="eyeblue.gif" hspace="3" vspace="3"
border="0" alt="blue eye image" align="middle"> Visual Perception
</NOBR>

<BR>[Optometrist] [Neurologist]<BR>
[Educational Psychologist]<BR>
[Orton-Gillingham Practitioner]<BR>
[Occupational Therapist]
</TD>
<TD VALIGN=TOP COLSPAN=2><INPUT TYPE=CHECKBOX NAME=REVERSALS>Difficulty
organizing the position
and shape of input. <BR>     Example:(u=n,
E=3, W=M, b=d=p=g=q,7=L, rotations/reversals).
<BR>
<INPUT TYPE=CHECKBOX NAME=REVERSALS>Difficulty focusing on a figure
with background.<BR>
     (Difficulty locating things; Skipped
words, lines, rereads).
<BR>
<INPUT TYPE=CHECKBOX NAME=REVERSALS>Judging distance and depth
(appears clumsy).<BR>

<INPUT TYPE=CHECKBOX NAME=REVERSALS>Disoriented about position in
space, poor sense of direction.<BR>
<INPUT TYPE=CHECKBOX NAME=REVERSALS>Visual Motor: Inept at jump rope,
hopscotch, ball sports.<BR>
</TD></TR></TABLE>
<BR>
<INPUT TYPE=submit VALUE="Submit Survey">
</form>
</body>
</html>

Q:
A:
Whenever you have a

<INPUT TYPE=CHECKBOX NAME=DISABILITY>

the browser does not really care what is following the tag. The text, like
"Forming letters legibly" is displayed, but there is no way in your
example to tell which check box was selected.

There are two solutions to the issue. One is to name each checkbox
different, and not DISABILITY. Like

<INPUT TYPE=CHECKBOX NAME=UNDERST>Understanding what is read<BR>
<INPUT TYPE=CHECKBOX NAME=REMEMBER>Remembering what was read<BR>
<INPUT TYPE=CHECKBOX NAME=SPELL>Spelling<BR>
<INPUT TYPE=CHECKBOX NAME=LETTER>Forming letters legibly<BR>
<INPUT TYPE=CHECKBOX NAME=HANDWRI>Handwriting legibly<BR>
<INPUT TYPE=CHECKBOX NAME=WRISEN>Writing sentences & paragraphs<BR>

and so on. Submitting this form you ill get the variables that are checked
with some values in the http request that goes to start the CGI when the
user presses the submit button.

A different solution is to specify a value for each disability, like

<INPUT TYPE=CHECKBOX NAME=DISABILITY VALUE="UNDERST">Understanding what is
read<BR>
<INPUT TYPE=CHECKBOX NAME=DISABILITY VALUE="REMEMBER">Remembering what was
read<BR>

and so on. This way you should check in the CGI input what values the CGI
variable DISABILITY has. A single CGI variable can have several values,
like an array. Perl modules like CGI.pm or cgi-lib.pl can handle such CGI
input, though this may be a bit more difficult for a starter than the
first solution. On the other hand later development in your form may
result more complex but easier to maintain CGI script. Please consult the
documentation of CGI.pm and/or cgi-lib.pl

A final comment: altough most browsers support your coding this is not
standard to have any name in an HTML tag unquoted. For example instead of

<INPUT TYPE=CHECKBOX NAME=DISABILITY>

you should write

<INPUT TYPE="CHECKBOX" NAME="DISABILITY">

to be standards compliant.

Regards,
Peter

[ back to toc ]