Link to home
Start Free TrialLog in
Avatar of ellandrd
ellandrdFlag for Ireland

asked on

Check if checkbox is checked or unchecked in perl

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
Avatar of manav_mathur
manav_mathur

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
ASKER CERTIFIED SOLUTION
Avatar of kandura
kandura

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozo
           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} ;