in reply to Re: How to implement a checkbox that will send data to db
in thread How to implement a checkbox that will send data to db

Hi, I did try to implement it using a list box :
# get Discontinued my $sql = qq!SELECT DISTINCT("Discontinued") AS disc FROM "Products" ORDER BY 1 DESC !; my $dr = $dbh->selectall_arrayref($sql); # Make up a pulldown menu for Discontinued my $discs = qq!<option value="">Select option</option>!; for my $row (@$dr) { $discs .= qq!<option value="$row->[0]">$row->[0]</option>\n!; }
Discontinued :<select name="discontinued"> $discs </select><br/>
But if I select 1 i.e. True the update goes through and if select 0 i.e. False it sends a null value which is throwing the following error :
DBD::Pg::db do failed: ERROR: invalid input syntax for type boolean: +"" at /usr/share/perlproj/cgi-bin/editprod.pl line 44
Any I idea why it will send 1 but not 0 ? Many Thanks Rgds Terry

Replies are listed 'Best First'.
Re^3: How to implement a checkbox that will send data to db
by terrykhatri (Acolyte) on Jul 10, 2014 at 10:56 UTC
    Fixed it by getting the results in character 'f' and 't' ( instead of numeric of 0 and 1) from database by changing the query.
    # get Discontinued my $sql = qq!SELECT DISTINCT("Discontinued")::CHAR AS disc FROM "Products" ORDER BY 1 DESC !;