Gossamer Forum
Home : Products : Links 2.0 : Customization :

Checkbox field in add.cgi

Quote Reply
Checkbox field in add.cgi
Please....

How to ????

(...and if the user has to go to add_failure he still have some boxes CHECKED!)
Quote Reply
Re: Checkbox field in add.cgi In reply to
ds,

Can you be a bit more specific here? Checkbox field for what in add.cgi? Actually, you wouldn't put a checkbox field in add.cgi, you would put it in the add.html and add_error.html template files (if using templates) or in the site_html_add_form and site_html_add_failure subroutines in site_html.pl (if not using templates or this is version 1.xx).
Quote Reply
Re: Checkbox field in add.cgi In reply to
i think he's talking about the site_html_add_form and site_html_add_failure subroutines in site_html.pl.

i alsow would like to have checkboxes, but it seems immossible to make the checkboxes checked in the site_html_add_failure subroutine IF a user checked them.

[This message has been edited by chrishintz (edited March 21, 1999).]
Quote Reply
Re: Checkbox field in add.cgi In reply to
You need to include a value= parameter in the input tag in site_html_add_failure.

For example (this example is for a radio button, not a checkbox, but the concept is the same):

I allow users to specify whether or not they want to Receive Mail concerning news affecting their links when they submit the link. In the add form, I have:

Code:
if ($in{'ReceiveMail'} eq "Yes") {
my $radio_button = qq|Receive Mail:
<input type="radio" name="ReceiveMail" value="Yes" checked> Yes
<input type="radio" name="ReceiveMail" value="No"> No;
}
else {
my $radio_button = qq|Receive Mail:
<input type="radio" name="ReceiveMail" value="Yes"> Yes
<input type="radio" name="ReceiveMail" value="No" checked> No;
}

If you do this in site_html.pl, just put that code where it should appear in the form. If using templates, then add:

radio_button => $radio_button

to the list for the add_error.html template loader and use <%radio_button%> in the template where you need it.

I hope this helps.

[This message has been edited by Bobsie (edited March 21, 1999).]
Quote Reply
Re: Checkbox field in add.cgi In reply to
elms,

It goes in sub site_html_add_failure in site_html_templates.pl.

I didn't specifically state that because I assumed that anyone using templates would know that you can't include code like that in a template and that it has to be done in the subroutine that controls the template. That's what I get for assuming. Wink

[This message has been edited by Bobsie (edited March 22, 1999).]
Quote Reply
Re: Checkbox field in add.cgi In reply to
Bobsie,

Where would you put this code if you are using templates:

Code:
if ($in{'ReceiveMail'} eq "Yes") {
my $radio_button = qq|Receive Mail:
<input type="radio" name="ReceiveMail" value="Yes" checked> Yes
<input type="radio" name="ReceiveMail" value="No"> No;
}
else {
my $radio_button = qq|Receive Mail:
<input type="radio" name="ReceiveMail" value="Yes"> Yes
<input type="radio" name="ReceiveMail" value="No" checked> No;
}

Thanks in advance,
elms
Quote Reply
Re: Checkbox field in add.cgi In reply to
Bobsie,

The only reason I asked was because I was getting an error about an unknown tag when I did insert the code in site_html_templates.pl in the add failure routine. It did not recognize the $radio_button. I must be missing something. I will try again...

Thanks,
elms
Quote Reply
Re: Checkbox field in add.cgi In reply to
Bobsie,

This is what I have for the add failure routine:

Code:
sub site_html_add_failure {
# --------------------------------------------------------
# This routine determines how the add failure page will look like.

my ($errormsg) = shift;
my $category = &build_select_field ("Category", "$in{'Category'}");
delete $in{'Category'};
my $altcategories = &build_select_field ("AltCategories","$in{'AltCategories'}","AltCategories","MULTIPLE Size=3");
delete $in{'AltCategories'};

if ($in{'ReceiveMail'} eq "Yes") {
my $radio_button = qq|Receive Mail:
<input type="radio" name="ReceiveMail" value="Yes" checked> Yes
<input type="radio" name="ReceiveMail" value="No"> No;
}
else {
my $radio_button = qq|Receive Mail:
<input type="radio" name="ReceiveMail" value="Yes"> Yes
<input type="radio" name="ReceiveMail" value="No" checked> No;
}

&html_print_headers;
print &load_template ('add_error.html', {
radio_button => $radio_button,
AltCategories => $altcategories,
Category => $category,
error => $errormsg,
%in,
%globals
});

}

This is the error I am getting:

Code:
Error including libraries: syntax error at /www/htdocs/admin/site_html_templates.pl line 227, near "my $radio_button = qq|Receive Mail"

Make sure they exist, permissions are set properly, and paths are set correctly.

Sorry for the last post, I never got that far to get the unknown tag. I think that was when I forgot to put the ifelse code in.

I cannot figure out where the syntax error could be. This error occurs when I click on add resource to go to add.cgi . Is there something wrong with one of my perl modules?

Thanks in advance,
elms



[This message has been edited by elms (edited March 24, 1999).]
Quote Reply
Re: Checkbox field in add.cgi In reply to
elms,

Quote:
If using templates, then add:

radio_button => $radio_button

to the list for the add_error.html template loader and use <%radio_button%> in the template where you need it.

That is done in site_html_templates.pl.
Quote Reply
Re: Checkbox field in add.cgi In reply to
elms,

Try:

Code:
if ($in{'ReceiveMail'} eq "Yes") {
my $radio_button = qq|Receive Mail:
<input type="radio" name="ReceiveMail" value="Yes" checked> Yes
<input type="radio" name="ReceiveMail" value="No"> No|;
}
else {
my $radio_button = qq|Receive Mail:
<input type="radio" name="ReceiveMail" value="Yes"> Yes
<input type="radio" name="ReceiveMail" value="No" checked> No|;
}

I left out the closing "|" for the qq. My apologies. I have a problem seeing things and sometimes leave things out in my rush to answer questions. I have to learn to be more careful.
Quote Reply
Re: Checkbox field in add.cgi In reply to
Bobsie,

Now I am feeling like I am doing something wrong. This is section where I have ReceiveMail in add.html:

Code:
<tr>
<td align="right" valign="top">Receive Email:</td>
<td valign="top">  <input type="radio" name="ReceiveMail"
value="Yes" checked> <b>Yes</b> <input type="radio" name="ReceiveMail" value="No"> <b>No</b><br><br></td>
</tr>

I have cut and paste your post to site_html_templates.pl

I am getting no more errors but the section in add_error.html:

Code:
<tr><td align="right" valign="top">Receive Email:</td>
<td valign="top"><%radio_button%><br><br></td></tr>

where <%radio_button%> is suppose to insert the "input type and radio button" is not showing up. When I view source in the add error page it just shows up as:

Code:
<tr><td align="right" valign="top">Receive Email:</td>
<td valign="top"><br><br></td></tr>

I must be missing something. I appreciate all your help. I wish I had a little more time to learn perl so I could troubleshoot this a little more. I do not know where to look.

Thanks in advance,
elms


[This message has been edited by elms (edited March 25, 1999).]
Quote Reply
Re: Checkbox field in add.cgi In reply to
Here is the code I use in add.html:

Code:
my ($errormsg) = shift;
my $category = &build_select_field ("Category", "$in{'Category'}");
delete $in{'Category'};
my $radio;

if ($in{'ReceiveMail'} eq "Yes") {
$radio_button = qq|<input type="radio" name="ReceiveMail" value="Yes" checked> <b>Yes</b>
<input type="radio" name="ReceiveMail" value="No"> <b>No</b>|;
}
else {
$radio_button = qq|<input type="radio" name="ReceiveMail" value="Yes"> <b>Yes</b>
<input type="radio" name="ReceiveMail" value="No" checked> <b>No</b>|;
}

&html_print_headers;
print &load_template ('add_error.html', {
error => $errormsg,
Category => $category,
radio_button => $radio_button,
%in,
%globals
});
}

And finally, here is the code I use in add_failure.html:

Quote:
<tr><td align="right" valign="middle">
<b>Receive Email:</b>
</td><td valign="top">
<b>If you do not want to receive email about changes to<br>Bob's Good Stuff Lists that may affect this resource,<br>select "No"</b>
<%radio_button%><br>
</td></tr></table>

I hope this helps.
Quote Reply
Re: Checkbox field in add.cgi In reply to
One of the problems was:

Code:
if ($in{'ReceiveMail'} eq "Yes") {
my $radio_button = qq|Receive Mail:
<input type="radio" name="ReceiveMail" value="Yes" checked> Yes
<input type="radio" name="ReceiveMail" value="No"> No|;
}
else {
my $radio_button = qq|Receive Mail:
<input type="radio" name="ReceiveMail" value="Yes"> Yes
<input type="radio" name="ReceiveMail" value="No" checked> No|;
}

What was happening is $radio_button was scoped using my(). When you declare a variable with my(), it's only valid in the current block, as soon as you leave the block, the value disappears. So as soon as you left the if { } block, $radio_button would no longer be defined.

Fix is to either remove my(), or add it to the top:

my $radio_button;
if {
..
}
else {
..
}

Cheers,

Alex
Quote Reply
Re: Checkbox field in add.cgi In reply to
Alex,

Which was exactly what I showed in the final code. The my() was at the top and no longer in the if statements.

[This message has been edited by Bobsie (edited March 26, 1999).]
Quote Reply
Re: Checkbox field in add.cgi In reply to
I know this has been long drawn out and I appreciate all the help. Bobsie your post helped out a lot. It does produce the <%radio_button%> now in the add_error.html but I think there is something wrong but almost there.

This is the code I have in site_html_templates.html:

Code:
my $radio_button;
if ($in{'ReceiveMail'} eq "Yes") {
$radio_button = qq|<input type="radio" name="ReceiveMail" value="Yes" checked> <b>Yes</b>
<input type="radio" name="ReceiveMail" value="No"> <b>No</b>|;
}
else {
$radio_button = qq|<input type="radio" name="ReceiveMail" value="Yes"> <b>Yes</b>
<input type="radio" name="ReceiveMail" value="No" checked> <b>No</b>|;
}

If I set this line:
Code:
($in{'ReceiveMail'} eq "Yes")
then my add_error.html always has the radio button at "Yes" even though in add.html I choose "No"

If I set this line:
Code:
($in{'ReceiveMail'} eq "No")
then my add_error.html always has the radio button at "No" even though in add.html I choose "Yes"

I even copied your code straight from each add.html and add_error.html and it was still not going to the "else" statement for some reason. There must be gremlins at work because I know they are working at your site Bobsie. Thanks Alex for your reply. I think I have the right syntax now but I do not know why it is not going to the "else" statement.

Thanks so much Bobsie and Alex,
elms
Quote Reply
Re: Checkbox field in add.cgi In reply to
elms,

Quote:
If I set this line:

code:


($in{'ReceiveMail'} eq "Yes")

I am not following; where are you setting that? It should be part of an if statement as in:

Quote:
if ($in{'ReceiveMail'} eq "Yes") {
Quote Reply
Re: Checkbox field in add.cgi In reply to
Sorry, got lazy and did not paste the rest of the rest. What I meant was:

When the code is like this:
Code:
my $radio_button;
if ($in{'ReceiveMail'} eq "Yes") {
$radio_button = qq|<input type="radio" name="ReceiveMail" value="Yes" checked> <b>Yes</b>
<input type="radio" name="ReceiveMail" value="No"> <b>No</b>|;
}
else {
$radio_button = qq|<input type="radio" name="ReceiveMail" value="Yes"> <b>Yes</b>
<input type="radio" name="ReceiveMail" value="No" checked> <b>No</b>|;
}

then my add_error.html always has the radio button at "Yes" even though in add.html I choose "No"

When the code is like this:
Code:
my $radio_button;
if ($in{'ReceiveMail'} eq "No") {
$radio_button = qq|<input type="radio" name="ReceiveMail" value="Yes" checked> <b>Yes</b>
<input type="radio" name="ReceiveMail" value="No"> <b>No</b>|;
}
else {
$radio_button = qq|<input type="radio" name="ReceiveMail" value="Yes"> <b>Yes</b>
<input type="radio" name="ReceiveMail" value="No" checked> <b>No</b>|;
}

then my add_error.html always has the radio button at "No" even though in add.html I choose "Yes"

Sorry for the confusion,
elms

[This message has been edited by elms (edited March 27, 1999).]
Quote Reply
Re: Checkbox field in add.cgi In reply to
elms,

Something is not coded right or something is in the wrong place. Can you send me (or post) your add.html, add_error.html and site_html_add_failure routines? Thanks.

------------------
Bob Connors
bobsie@orphanage.com
www.orphanage.com/goodstuff/





Quote Reply
Re: Checkbox field in add.cgi In reply to
This code works beautifully on the Add_error template, not so well on modify
template. I am using the Password Modify mod by Phoenix, but that should not
interfere with the operation of the this mod to my knowledge. My
sub_html_modify_form looks like this...
Code:
my %rec = @_;
my $category = &build_select_field ("Category", "$rec{'Category'}");
my $radio1;
if ($in{'Continuing'} eq "Yes") {
$radio_Continuing = qq|<font face="Arial" size="2">
<INPUT TYPE="RADIO" NAME="Continuing" value="">No
<INPUT TYPE="RADIO" NAME="Continung" VALUE="Yes" CHECKED>Yes|;
}
else {
$radio_Continuing = qq|<font face="Arial" size="2">
<INPUT TYPE="RADIO" NAME="Continuing" value="" CHECKED>No
<INPUT TYPE="RADIO" NAME="Continuing" VALUE="Yes">Yes|;
}
my $radio2;
if ($in{'NetReports'} eq "Yes") {
$radio_NetReports = qq|<font face="Arial" size="2">
<INPUT TYPE="RADIO" NAME="NetReports" value="">No
<INPUT TYPE="RADIO" NAME="NetReports" VALUE="Yes" CHECKED>Yes|;
}
else {
$radio_NetReports = qq|<font face="Arial" size="2">
<INPUT TYPE="RADIO" NAME="NetReports" value="" CHECKED>No
<INPUT TYPE="RADIO" NAME="NetReports" VALUE="Yes">Yes|;
}
.
. # snip for brevity
.
&html_print_headers;
print &load_template ('modify.html', {
category => $category,
radio_Continuing => $radio_Continuing,
radio_NetReports => $radio_NetReports,
.
. # snip for brevity
.
%rec,
%globals
});
}
A little help on this one, anybody?

[This message has been edited by oldmoney (edited August 15, 1999).]
Quote Reply
Re: Checkbox field in add.cgi In reply to
Ok, one down, one to go... this mod works fine in conjunction with
Password Modify if all occurences of $in are replaced by $rec. I still
haven't been able to get Password Modify to recognize the <%Category%>
though... Frown

[This message has been edited by oldmoney (edited August 17, 1999).]
Quote Reply
Re: Checkbox field in add.cgi In reply to
I am having a problem with adding the ReceiveMail field in the add.cgi template files.

The main problem is that on the Success Page,the following shows up:

Code:
Receive Email Updates: Yes~~Yes

I have added all the codes Bobsie provided for the site_html_templates.pl and in the add.html and add_error.html templates. I added the same codes in add_error.html to the add_confirm.thml file. Everything works except that the final confirmation screen (add_success.html) shows Yes~~Yes and I receive the same information in the email message.

Also, in the validation screen, the ReceiveMail field shows up as "Yes" even when I tested putting "No" in the ReceiveMail field.

Any ideas about how to get this to work?

Thanks.

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited September 06, 1999).]
Quote Reply
Re: Checkbox field in add.cgi In reply to
Eliot,

Please email me attachments of all the 'add' template files involved and an extract of the site_html_templates.pl add subroutines as you have them coded. A copy of links.def would also help.

As of right now, all I can say is that the Yes~~Yes indicates a duplicate variable being declared/used someplace.