Fellow Monks, I am trying to display a checklist in a perl Tk program i'm writing. I am having trouble with the Tk::Checkbutton. When I use the following code the checkbuttons do not show up. If I make the arrays into single scalars the checkboxes show up but when I check 1 they all are checked because it's only 1 value for all. So I think I need an array to hold each checkbutton and an array to hold each checkbutton value.
Please tell me what i'm doing wrong. Thanks!
my $x = 1; #index for table rows my $t=0; #index for checkbuttons and values my @checkboxvalue; #array to hold the checkutton values for each chec +kbox my @checkbox; #array to hold the checkbuttons for each row foreach my $m (@unpaidbills) { $checkbox[$t]= $bill_table->Checkbutton(-variable=>\$checkboxvalue[ +$t]); $bill_table->put($x,0, $checkbox[$t]); $bill_table->put($x,1, $m->{bill_name}); $bill_table->put($x,2, "\$$m->{bill_amountdue}"); $bill_table->put($x,3, "$main::month\/$m->{bill_datedue}\/$mai +n::year"); $bill_table->put($x,4, "\$$m->{bill_amountpaid}"); $bill_table->put($x,5, $m->{bill_datepaid}); @paymethods = BPP::PAYMETHODS->retrieve($m->{bill_paymethod}); $bill_table->put($x,6, map{$_->{paymethod_desc}}@paymethods); my $paybill = $bill_table->Button(-text=>'Submit', -command=>sub{ if ($checkboxvalue[$t] == 1) +{ &BillPaymentScreen($m->{bill_name}, $m->{bill_amountdue}, $m->{bill_da +tedue}, $m->{bill_id}, $tltop) } else { print "checkbox not paid"} + }#end sub )->pack; $bill_table->put($x,7, $paybill); $x++; }#end foreach loop
Update> I get the following error: Use of uninitialized value in numeric eq (==) at BPP/BILL.pm line 148. Which is this line: if ($checkboxvalue[$t] == 1

In reply to Array of TK::Checkbuttons not acting appropriately by mikasue

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.