Gossamer Forum
Home : Products : DBMan : Installation :

Multiple checkboxes and writing to table cell

Quote Reply
Multiple checkboxes and writing to table cell
I am attempting a task using multiple checkboxes that each have a db field.

If a user checks one or more of the available boxes, all the result shows in a single table cell. I am getting a syntax error that I haven't been able to figure out.

Here's my code:

<tr>
<td colspan="2"><p>|; # to close off any previous print qq| statement
if ($rec{'Interest_fresh'})
print qq|<$font>$rec{'Interest_fresh'}</font>|
elseif ($rec{'Interest_salt'})
print qq|<$font>$rec{'Interest_salt'}</font>|
elseif ($rec{'Interest_offshore'})
print qq|<$font>$rec{'Interest_offshore'</font>|
elseif ($rec{'Interest_fly'})
print qq|<$font>$rec{'Interest_fly'}</font>|
</td></tr>

This board is treating break tags a little weird. There should be a break tag after the first 3 </font> tags and just before first 3 |s.

Could one of you perl dudes or dudettes point out the errors in my feeble attempts?

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Multiple checkboxes and writing to table cell In reply to
You need to replace the following codes:

Code:

if ($rec{'Interest_fresh'})


with the following codes:

Code:

if ($in{'Interest_fresh'}) {


if this hack is being used for search results. BTW: You are missing right brackets and left brackets in your original codes. Also, you are not using correct operators for your print statements, you are missing the closing semi-colon.

You should replace all your codes with the following codes:

Code:

<tr>
<td colspan="2"><p>
|;
if ($in{'Interest_fresh'}) {
print qq|<$font>$rec{'Interest_fresh'}</font>|;
}
elsif ($in{'Interest_salt'}) {
print qq|<$font>$rec{'Interest_salt'}</font>|;
}
elsif ($in{'Interest_offshore'}) {
print qq|<$font>$rec{'Interest_offshore'}</font>|;
}
elsif ($in{'Interest_fly'}) {
print qq|<$font>$rec{'Interest_fly'}</font>|;
}
print qq|
</td></tr>


Notice all the bolded red codes.

Hope this helps. (BTW: There is a Customization Forum for DBMAN...Wink).

Regards,

Eliot Lee
Quote Reply
Re: Multiple checkboxes and writing to table cell In reply to
Thanks Eliot,

Here's my code now.

<tr><td colspan="2"><p>
|;
if ($in{'Interest_fresh'}) {
print qq|<$font>$rec{'Interest_fresh'}</font>|;
}
elseif ($in{'Interest_salt'}) {
print qq|<$font>$rec{'Interest_salt'}</font>|;
}
elseif ($in{'Interest_offshore'}) {
print qq|<$font>$rec{'Interest_offshore'</font>|;
}
elseif ($in{'Interest_fly'}) {
print qq|<$font>$rec{'Interest_fly'}</font>|;
}
print qq|
</td></tr>


and here's the error I'm getting.

CGI ERROR
==========================================
Error Message : Error loading required libraries.
Check that they exist, permissions are set correctly and that they compile.
Reason: syntax error at ./partner_html.pl line 539, near "}"
syntax error at ./partner_html.pl line 544, near "print qq|<$font>$rec{'Interest_fly'}


Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Multiple checkboxes and writing to table cell In reply to
The problem is on this line:

print qq|<$font>$rec{'Interest_offshore'</font>|;

Should be:

print qq|<$font>$rec{'Interest_offshore'}</font>|;

notice it was missing the right bracket before </font>

Hope this helps

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Multiple checkboxes and writing to table cell In reply to
Well dog-gone it. Now I'm getting

CGI ERROR
==========================================
Error Message : Error loading required libraries.
Check that they exist, permissions are set correctly and that they compile.
Reason: syntax error at ./partner_html.pl line 539, near "}"
syntax error at ./partner_html.pl line 542, near "}"

Script Location : /home/httpd/virtual-domains/fishhoo/cgi-bin/team/partner/db.cgi
Perl Version : 5.00503
Setup File : partner.cfg


Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Multiple checkboxes and writing to table cell In reply to
LoisC is correct...I have edited my previous posting...The problem could be with codes above or below the codes I provided...Try checking the lines around where the error message appears.

BTW: The better approach is to put the codes I provided (without the table codes) in the sub html_view_success routine.

Good luck!

Regards,

Eliot Lee
Quote Reply
Re: Multiple checkboxes and writing to table cell In reply to
Yes, I made that correction but no help. I have posted the entire file at http://www.fishhoo.com/.../partner_html-pl.txt

Any further help will be appreciated.

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Multiple checkboxes and writing to table cell In reply to
Nope...you didn't...I suggested putting the codes in the sub html_view_success, you put them in the sub html_record routine.

Anyway...I don't see any syntax errors with the codes you've added...

Regards,

Eliot Lee
Quote Reply
Re: Multiple checkboxes and writing to table cell In reply to
Here's the way the code should be in sub html_record:

Code:

|;
if ($rec{'Interest_fresh'}) {
print qq|<$font>$rec{'Interest_fresh'}</font>|;
}
elsif ($rec{'Interest_salt'}) {
print qq|<$font>$rec{'Interest_salt'}</font>|;
}
elsif ($rec{'Interest_offshore'}) {
print qq|<$font>$rec{'Interest_offshore'}</font>|;
}
elsif ($rec{'Interest_fly'}) {
print qq|<$font>$rec{'Interest_fly'}</font>|;
}
print qq|
Notice that you had "elseif" instead of the correct "elsif." Also, since this is in sub html_record, you need to use $rec{'FieldName'} and not $in{'FieldName'}. (I know you were just doing what you were told, but it was incorrect.)

A couple of other things -- with all of your "elsif" statements, you are making your checkboxes mutually exclusive. If a user had checked both Interest_fresh and Interest_salt, only the first one would appear. If you want all of the options to appear, use if instead of elsif.


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Multiple checkboxes and writing to table cell In reply to
Well look who woke up and saved the day. You are my hero. There are still just a few little things to clean up but I can handle that. I hope.

Thanks,

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Multiple checkboxes and writing to table cell In reply to
It works perfectly. Just what I wanted. Take a look http://www.fishhoo.com/...w_records=1&ID=*.

Thanks again,

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Multiple checkboxes and writing to table cell In reply to
Oops...I overlooked those codes...I fixed my previous post. Wink

Regards,

Eliot Lee
Quote Reply
Re: Multiple checkboxes and writing to table cell In reply to
Yay!!!! Looks very good. Smile

JPD
http://www.jpdeni.com/dbman/