I'm using Tk as my user interface and I'm listing rows of data from a database. The first widget in each row is a button that calls a subroutine, the next items in each row is a radio button group denoting the "status" of each row, then there is some more data. Something like this:

[Update]  (*)0 ( )1 ( )2 {text field}  {text field} .....
[Update]  (*)0 ( )1 ( )2 {text field}  {text field} .....
[Update]  (*)0 ( )1 ( )2 {text field}  {text field} .....
[Update]  (*)0 ( )1 ( )2 {text field}  {text field} .....

I want the user to be able to change the status by selecting another radio button besides the default, hit the button and the subroutine will change the data in the database accordingly.

The problem I'm having is getting the correct data back to the subroutine. I want to ship back the id of the database row and the newly selected status. After pulling the data from the database, I'm creating an Array of Hashes and displaying the data. The pertinent code follows:

while (@row = $sth->fetchrow_array()) {
    $count ++;
    $id = $row[0];
    $AoH[$count]{id} = $row[0];
    $AoH[$count]{transstatus} = $row[7];

my $b1 = $f1->Button(-text => 'Update', -command => [\&update_record, $id, $AoH[$count]{transstatus}])->grid(-column => 1, -row => $count);

foreach (qw/0 1 2/) {
my $r1 = $f1->Radiobutton(-text => $_, -value => $_, -variable => \$AoH[$count]{transstatus})->grid(-column => ($_ + 2), -row => $count);
}
[......]



My subroutine, update_record(), expects two arguments: the id of the database record and the new status. I can put the id number from the database query into the variable $id and ship it because it will not change. However, I cannot do this to the status, since the value is tied to a radiobutton group. So, what I think I want to do is reference the actual values of the array of hashes element, so that when the user changes the radio button, the actual value of the array of hashes element changes, instead of a copy of the value changing, and this is was is passed to the subroutine, but I'm getting lost in the referencing/dereferencing.


Suggestions on how to make this work?  Am I making it too hard?

-Mike


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to