Gossamer Forum
Home : Products : DBMan : Customization :

Can blank fields not be displayed?

Quote Reply
Can blank fields not be displayed?
If someone does not fill in a field, is there a way to not have the field not displayed on the screen?

Guess it would still have to record a blank in the data file so items line up.
Quote Reply
Re: Can blank fields not be displayed? In reply to
Yes.

Let's say your form in sub html_record_form looks like this:

Code:
<table>
<tr><td>Name:</td>
<td>$rec{'Name'}</td></tr>
<tr><td>Userid:</td>
<td>$rec{'Userid'}</td></tr>
<tr><td>Address:</td>
<td>$rec{'Address'}</td></tr>
<tr><td>Gender:</td>
<td>$rec{'Gender'}</td></tr>
<tr><td>Favorite Color:</td>
<td>$rec{'Color'}</td></tr>
</table>
|;

For demonstration purposes, we'll assume that Address and Color are optional fields.

Code:
<table>
<tr><td>Name:</td>
<td>$rec{'Name'}</td></tr>
<tr><td>Userid:</td>
<td>$rec{'Userid'}</td></tr>|;
if ($rec{'Address'}) {
print qq|

<tr><td>Address:</td>
<td>$rec{'Address'}</td></tr>|;
}
print qq|

<tr><td>Gender:</td>
<td>$rec{'Gender'}</td></tr>|;
if ($rec{'Color'}) {
print qq|

<tr><td>Favorite Color:</td>
<td>$rec{'Color'}</td></tr>|;
print qq|

</table>
|;

------------------
JPD





Quote Reply
Re: Can blank fields not be displayed? In reply to
is there an easier command to apply to all fields? :-)
Quote Reply
Re: Can blank fields not be displayed? In reply to
Hi, TM.

It doesn't get much easier than that. Smile

It is possible, however. In my database, it is always the same format, and is very self-explanatory what everything is. I don't need to write out:

Title: $rec{'Title'}
Category: $rec{'Category'}
Description: $rec{'Description'}
Contact Phone Number: $rec{'Phone'}

Instead, I leave off the description of the line, and any records that are empty -- for example if a record doesn't have a contact phone number -- then nothing is displayed for that particular record.

However, if you have descriptions for the records, then you'd want to go with JPD's suggestion. Smile

--Lee
Quote Reply
Re: Can blank fields not be displayed? In reply to
Here is the code I applied it to, but i am getting the error page now. :-) (see below)
Am i doing something wrong? I notice in the examples above you don't have the input tags etc in there. This is part of my
sub html_record_form

<table>
<tr><td>NAME FrownLast name, first, middle)</td>
<td><input type="text" name="NAME" VALUE="$rec{'NAME'}"></td></tr>|;
if ($rec{'PROGRAM'}) {
print qq|
<tr><td>Program:</td><td><input type="text" name="PROGRAM" VALUE="$rec{'PROGRAM'}"></td></tr>|;
}
print qq|
if ($rec{'DEGREE'}) {
print qq|
<tr><td>Degree Sought:</td><td><input type="text" name="DEGREE" VALUE="$rec{'DEGREE'}"></td></tr>|;
}
print qq|
if ($rec{'GPA'}) {
print qq|
<tr><td>GPA:</td><td><input type="text" name="GPA" VALUE="$rec{'GPA'}"></td></tr>|;
}
print qq|
if ($rec{'GREs'}) {
print qq|
<tr><td>GRE Scores:</td><td><input type="text" name="GREs" VALUE="$rec{'GREs'}"></td></tr>|;
}
print qq|
</TABLE>
|;


error i get...

CGI ERROR
==========================================
Error Message : Error loading required libraries.
Check that they exist, permissions are set correctly and that they compile.
Reason: Unterminated <> operator at F://netscapedocs/cgi-bin/database2//html.pl line 85.

Script Location : F:\NetscapeDocs\cgi-bin\database2\db.pl
Perl Version : 5.00503
Setup File : default.cfg
Quote Reply
Re: Can blank fields not be displayed? In reply to
I made a mistake earlier. This should not be in sub html_record_form. It should be in sub html_record. I'm sorry.

Put back sub html_record_form as you had it and apply the changes to sub html_record.

There isn't any easier way to skip blank fields, I'm afraid.


------------------
JPD





Quote Reply
Re: Can blank fields not be displayed? In reply to
sorry to be a pain in the @$$, but still getting cgi errors. Does this look alright? Hope this is ok to read since it wraps around in box.. (error message below)

<TABLE WIDTH="600" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC"><TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="80"><$font_color>Name:</FONT></TD><TD WIDTH="400"> <$font>$rec{'NAME'}</Font></TD></TR>|;
if ($rec{'PROGRAM'}) {
print qq|
<TR><TD ALIGN="LEFT" VALIGN="TOP"><$font_color>Program:</FONT></TD>
<TD> <$font>$rec{'PROGRAM'}</Font></TD></TR>|;
}
print qq|
if ($rec{'DEGREE'}) {
print qq|
<TR><TD ALIGN="LEFT" VALIGN="TOP"><$font_color>Degree Sought:</FONT></TD>
<TD> <$font>$rec{'DEGREE'}</Font></TD></TR>|;
}
print qq|
if ($rec{'GPA'}) {
print qq|
<TR><TD ALIGN="LEFT" VALIGN="TOP"><$font_color>GPA:</FONT></TD>
<TD> <$font>$rec{'GPA'}</Font></TD></TR>|;
}
print qq|
if ($rec{'GREs'}) {
print qq|
<TR><TD ALIGN="LEFT" VALIGN="TOP"><$font_color>GREs:</FONT></TD>
<TD> <$font>$rec{'GREs'}</Font></TD></TR>|;
}
print qq|
|;


error message...

CGI ERROR
==========================================
Error Message : Error loading required libraries.
Check that they exist, permissions are set correctly and that they compile.
Reason: syntax error at F://netscapedocs/cgi-bin/database2//html.pl line 315, near "TR>"
syntax error at F://netscapedocs/cgi-bin/database2//html.pl line 320, near "}"

Script Location : F:\NetscapeDocs\cgi-bin\database2\db.pl
Perl Version : 5.00503
Setup File : default.cfg
Quote Reply
Re: Can blank fields not be displayed? In reply to
tm,

What code starts on line 315 and ends on 320 in your html.pl file? It seems the errors you're getting at least develope there.

Also, in your example, I am assuming you started the code with a print qq|?

--Lee
Quote Reply
Re: Can blank fields not be displayed? In reply to
I went back and just applied the extra code to 1 field and it worked, but when i went to apply to next field, i get errors. Is there some shareware similar to notepad that will tell me the line #'s? counting out 300 lines is getting old real fast! :-)

print qq|
<TABLE WIDTH="600" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="80"><$font_color>Name:</FONT></TD>
<TD WIDTH="400"> <$font>$rec{'NAME'}</Font></TD></TR> |;
if ($rec{'PROGRAM'}) {
print qq|
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="80"><$font_color>Program:</FONT></TD>
<TD WIDTH="400"> <$font>$rec{'PROGRAM'}</Font></TD></TR>|;
}
print qq|
if ($rec{'DEGREE'}) {
print qq|
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="80"><$font_color>Degree Sought:</FONT></TD>
<TD WIDTH="400"> <$font>$rec{'DEGREE'}</Font></TD></TR>|;
}
print qq|
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="80"><$font_color>GPA:</FONT></TD>
<TD WIDTH="400"> <$font>$rec{'GPA'}</Font></TD></TR>
Quote Reply
Re: Can blank fields not be displayed? In reply to
print qq|
<TABLE WIDTH="600" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="80"><$font_color>Name:</FONT></TD>
<TD WIDTH="400"> <$font>$rec{'NAME'}</Font></TD></TR>|;
if ($rec{'PROGRAM'}) {
print qq|
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="80"><$font_color>Program:</FONT></TD>
<TD WIDTH="400"> <$font>$rec{'PROGRAM'}</Font></TD></TR>|;
}
print qq|
if ($rec{'DEGREE'}) {
print qq|
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="80"><$font_color>Degree Sought:</FONT></TD>
<TD WIDTH="400"> <$font>$rec{'DEGREE'}</Font></TD></TR>|; (Error line here or)
print qq| (Error line here)
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="80"><$font_color>GPA:</FONT></TD><TD WIDTH="400"> <$font>$rec{'GPA'}</Font></TD></TR>
...50+ other table lines then....

</TABLE>
|;
}

as i mentioned before, i do not get error when extra code is applied to one field, but when i went to the second, i get the following error. still have 50+ fields to apply this to. :-)


CGI ERROR
==========================================
Error Message : Error loading required libraries.
Check that they exist, permissions are set correctly and that they compile.
Reason: syntax error at F://netscapedocs/cgi-bin/database2//html.pl line 314, near "TR>"
syntax error at F://netscapedocs/cgi-bin/database2//html.pl line 316, near "Font>|;
print"

Script Location : F:\NetscapeDocs\cgi-bin\database2\db.pl
Perl Version : 5.00503
Setup File : default.cfg
Quote Reply
Re: Can blank fields not be displayed? In reply to
DOS EDIT will display the cursor position you're at. Smile

I think I see an error in your syntax above:

Quote:
if ($rec{'PROGRAM'}) {
print qq|
<TR><TD ALIGN="LEFT" VALIGN="TOP"><$font_color>Program:</FONT></TD>
<TD> <$font>$rec{'PROGRAM'}</Font></TD></TR>|;
}

That part is OK. But, starting the next line:

Quote:
print qq|
if ($rec{'DEGREE'}) {
print qq|
<TR><TD ALIGN="LEFT" VALIGN="TOP"><$font_color>Degree Sought:</FONT></TD>
<TD> <$font>$rec{'DEGREE'}</Font></TD></TR>|;
}

You have an extra, redundant print qq marker. I believe that is what is causing your error. Take out the print qq| before every if(), and try it again.

--Lee
Quote Reply
Re: Can blank fields not be displayed? In reply to
THANKS SO MUCH!!!...i am rolling again.
Quote Reply
Re: Can blank fields not be displayed? In reply to
I have about 1/2 my fields coded with the text supplied above and stopped to test it out. I am not getting any errors, BUT I cannot see any records. If I do a search, view, list, it will say '2 records searched, but they are not showing.

Is there anything that would cause this? Anything I should be looking for? I am reviewing the code I have put in so far.

thanks so much!

Tim
Quote Reply
Re: Can blank fields not be displayed? In reply to
A few messages back, you asked

Quote:
Is there some shareware similar to notepad that will tell me the line #'s?

There are two that I have used and are very good. There's information about both of them at http://www.jpdeni.com/dbman/tutorial1.html .

If your fields are not showing up, you probably have left out a closing tag in your table. To check to see if this is true, do a search and then check the source code from your browser -- right click on your browser window and select "View Source" from the menu. Look to see if the information is there.

If you can't find the problem, post your html.pl file to a web-accessible directory and rename it to html_pl.txt. Then come back and tell me where I can pick it up and I'll look over it for you.



------------------
JPD







[This message has been edited by JPDeni (edited April 05, 2000).]
Quote Reply
Re: Can blank fields not be displayed? In reply to
source code is here. I think you can access it....
http://www.bio.psu.edu/goingcrazy/html_pl.txt

now i did notice program works in in IE, its in Netscape, and yes, it is a table tag. When i viewed the source code from the screen that told me there should be 20 records, the follow line of code appears with no ending tag. this is in the sub html_record area.

<TABLE WIDTH="600" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">

i am almost there...excuse the messy coding.
Quote Reply
Re: Can blank fields not be displayed? In reply to
Yes, IE is much more forgiving than Netscape is. Which is why I always suggest using Netscape to test things. It won't let you get away with bad stuff. Smile

I haven't found the table problem yet, but I did notice something.

You have a line

} #this should not be here, but i get error if it is not here!

It needs to be moved down just a bit. You've left out a closing } in the

if ($rec{'COURSESP'}) {

lines.

Finally figured out what your problem is.

At the end of the subroutine, you have

Code:
<TD WIDTH=400> <$font>$rec{'EMAIL'}</Font></TD></TR>
<p>
<p>
<b>Research Advisor:</b> Please review this and attached documents and the...
</table>

The last bit also needs to be in a table row. Or you need to end the table before the last bit.

You can have

Code:
<TD WIDTH=400> <$font>$rec{'EMAIL'}</Font></TD></TR>
<tr><td colspan=2><p>
<p>
<b>Research Advisor:</b> Please review this and attached documents and the...
</td></tr>
</table>


or you can have

Code:
<TD WIDTH=400> <$font>$rec{'EMAIL'}</Font></TD></TR></table>
<p>
<p>
<b>Research Advisor:</b> Please review this and attached documents and the...

Either one should work, but if you have text within a table, it must be within a cell.


------------------
JPD





Quote Reply
Re: Can blank fields not be displayed? In reply to
Thanks! You've got a sharp eye! Really do appreciaite all this! I could have done this w/o everyone that has helped this week!!! :-) !!!!

Tim
Quote Reply
Re: Can blank fields not be displayed? In reply to
You're very welcome. I'm just glad we could figure it all out.

We really do have a nice community here. It's great when everyone pitches in to help.


------------------
JPD