?
Solved

Check if checkbox is checked or unchecked in perl

Posted on 2005-03-02
3
Medium Priority
?
284 Views
Last Modified: 2011-10-03
i have this perl page that connects to ms access db using DBI

it display the values from  the db fields in a table.

the last field is yes/no datatype and i need to check if it is checked or unchecked.

$db = DBI->connect( "dbi:ODBC:PerlLink","","",{RaiseError => 1, printError => AutoCommit => 1})
or die "Unable to connect: " .$DBI::errstr . "\n";

$query = $db->prepare("SELECT * FROM tblData");

$query->execute;

$numrows = $query->rows;

print "<table border=1><tr><th>Record ID</th><th>Firstname</th><th>Lastname</th><th>Address</th><th>Age</th><th>Contact Number</th><th>Confirmed</th></tr>\n";

while (@array = $query->fetchrow_array)
{
      <<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>

                in here i need a perl script to check if the yes/no datatype field is checked or unchecked
                the yes/no field is called confirmed      

      <<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>


             my ($record_id, $firstname, $lastname, $address, $age, $contact, $confirmed) = @array;
             print "<tr><td>$record_id</td><td>$firstname</td><td>$lastname</td><td>$address</td><td>$age</td><td>$contact</td>" ;
             print "<form name=\"formcheckbox\"><td align=\"center\"><input type=\"checkbox\" name=\"confirmed\" value=0 onClick=\"SubmitForm(this, $record_id);\" $confirmed></td></form>" ;
}
print "</table>";

if this is unclear, please state so asap, so i can explain better as this problem is very urgent now and needs a solution
0
Comment
Question by:ellandrd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Expert Comment

by:manav_mathur
ID: 13438595
What you can do is print the value of $confirmed.
When I tested this, it returns 1 or 0 depending on whether the checked or not.

Manav
0
 
LVL 18

Accepted Solution

by:
kandura earned 2000 total points
ID: 13440664

            ### CHECKED is the html attribute to turn a checkbox on
            my $confirmed_yn = $confirmed ? 'checked' : '';  

            ### change $confirmed to $confirmed_yn here:
            ### (and also, I would set the value to $confirmed (so that it will hold 1 or 0)
            print "<form name=\"formcheckbox\"><td align=\"center\"><input type=\"checkbox\" name=\"confirmed\" value=0 onClick=\"SubmitForm(this, $record_id);\" $confirmed></td></form>" ;
0
 
LVL 84

Expert Comment

by:ozo
ID: 13440819
           my ($record_id, $firstname, $lastname, $address, $age, $contact, $confirmed) = @array;
             $confirmed ||= '';
             $confirmed &&= "checked";
            print "<tr><td>$record_id</td><td>$firstname</td><td>$lastname</td><td>$address</td><td>$age</td><td>$contact</td>\n";
            print qq{<form name="formcheckbox"><td align="center"><input type="checkbox" name="confirmed" value=0 onClick="SubmitForm(this, $record_id);" $confirmed></td></form>\n} ;
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question