ellandrd
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","","", {RaiseErro r => 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>Lastnam e</th><th> Address</t h><th>Age< /th><th>Co ntact 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><t d>$firstna me</td><td >$lastname </td><td>$ address</t d><td>$age </td><td>$ contact</t d>" ;
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
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","","",
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><
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><t
print "<form name=\"formcheckbox\"><td align=\"center\"><input type=\"checkbox\" name=\"confirmed\" value=0 onClick=\"SubmitForm(this,
}
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
my ($record_id, $firstname, $lastname, $address, $age, $contact, $confirmed) = @array;
$confirmed ||= '';
$confirmed &&= "checked";
print "<tr><td>$record_id</td><t d>$firstna me</td><td >$lastname </td><td>$ address</t d><td>$age </td><td>$ contact</t d>\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} ;
$confirmed ||= '';
$confirmed &&= "checked";
print "<tr><td>$record_id</td><t
print qq{<form name="formcheckbox"><td align="center"><input type="checkbox" name="confirmed" value=0 onClick="SubmitForm(this, $record_id);" $confirmed></td></form>\n}
When I tested this, it returns 1 or 0 depending on whether the checked or not.
Manav