am the user has asked for the wisdom of the Perl Monks concerning the following question:

How to poopulate the value in a list box based on the selection made from another list box am Using Tk and DBI module There are three listboxes namely "product,component and version" and the value for these listboxes has been populated from the DB based on the user loggin credentials. I have connected the DB using DBI moudle and prepare the query and executed and pass it to the respective listboxes. Now i want to know about the following fucntionality in perl if the user select the value from product combo box then coressponding value needs to be display in the component and version listboxes based on the selected product by the user from product listbox. How to get the user selected value from the product combo box. I need help to do the above functionality. please if somebody knows help me soon.

Replies are listed 'Best First'.
Re: Value population based on selection
by moritz (Cardinal) on Apr 28, 2009 at 09:34 UTC
    Please read through the previous questions here in the section Seekers of Perl Wisdom - surprisingly many of them ask about list boxes, and most of them suffer from the same problem as your question: they don't show any example code, don't tell what application they use (a GUI? which toolkit? or CGI?).

    Please read How (Not) To Ask A Question.

Re: Value population based on selection
by Anonymous Monk on Apr 28, 2009 at 09:42 UTC
      What I think the Anonymonk is asking (and it is a good question) is what kind of object are you using to create the combobox? I know of Tk::BrowseEntry and Tk::JComboBox, for example. With either of these, the easiest way to get the user-selected value is to create a variable to hold the selected value, and ask the combobox to put the selected value there. With Tk::BrowseEntry this is done with the -variable option passed to to constructor:
      my $value = ''; my $combo => $parent->BrowseEntry(-variable => \$value, ...);
      Tk::JComboBox does the same thing but the option is called -textvariable. You can then just read $value when you detect that a selection has been made.

      That's the 'How to get the user selected value' bit. To populate another list based on this value, well there's more than one way - you can reconfigure the -choices option:

      $combo->config(-choices => ['foo', 'bar', baz'...]);

      Or there are object methods that can remove items from the selection list and add others - see the docs for the combobox class you are using.