Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl and checkboxes 1

Status
Not open for further replies.

brownfox

Programmer
Jan 5, 2003
173
GB
I want to return the visitor an email with information specified from checkboxes in a html form. I've got the send mail working fine but I can't determine which checkboxes have been ticked or not. Here's my code - The form:
<input name=&quot;checkbox1&quot; type=&quot;checkbox&quot; value=&quot;on&quot;>
<input name=&quot;checkbox2&quot; type=&quot;checkbox&quot; value=&quot;on&quot;>
<input name=&quot;checkbox3&quot; type=&quot;checkbox&quot; value=&quot;on&quot;>

and the perl:
my $passwords=&quot;&quot;;

if($formdata{'checkbox1'} == 'on'){
$passwords = &quot;password1\n&quot;;
}
if($formdata{'checkbox2'} == 'on'){
$passwords = $passwords . &quot;password2\n&quot;;
}
if($formdata{'moves'} == 'on'){
$passwords = $passwords . &quot;password3\n&quot;;
}
BUT the return email sends out all 3 passwords regardless of how many checkboxes have been ticked or not? Any help much appreciated!
 
I have never had a problem with perl and checkboxes.

What code are you using to populate %formdata? cgi-lib.pl? What happens if you use CGI.pm instead?

 
for string comparisons you need to use a eq 'b' not a == 'b'

the strings are probably being taken as numeric 0 and so your statements is being evaluated as if 0==0 which would be true.

bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top