# Creating a drop-down list

This Job shows how to use a MySQL database table to create a drop-down list in a Talend Job.

This Job uses the following components:

* a tJava component to prepare the drop-down list and store the value selected by the user at runtime in the context variable.
* a tMysqlInput component to query the people information from the employee table.
* a tLogRow component to print the result on the console.

![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/creating_a_drop_down_list.png)

## Procedure

1. In Talend Studio, create a new Job named DropDownListExample.
2. Click the Context view and define a context variable of String type, call it name. This variable stores the drop-down value selected by the user at runtime.
3. Drop a tJava and a tMysqlInput component from the Palette onto the design workspace. Connect the tJava and the tMysqlInput component with a Trigger &gt; OnSubjobOk link.
4. Drop a tLogRow component and connect it with a Row &gt; Main link to tMysqlInput.
5. Double-click tJava and:
   1. add the following piece of Java code to prepare the drop-down list:
      ```
      String[] nameStrings = { "Elisa", "Nicolas", "Cedric", "Rabbit", "Mike","Sabrina","Stephane","Jim","John"};
                                  JFrame frame = new JFrame("Input Dialog Example");
                                  String returnValue = (String) JOptionPane.showInputDialog(frame,
                                  "Select the name you want to query?","Employee Information",JOptionPane.QUESTION_MESSAGE,null,nameStrings,nameStrings[0]);
                                  context.name=returnValue; //store the value to the context variable
      ```
   2. Store the value selected by the user at runtime in the context variable,
   3. Click Advanced settings and import the full path of the class used in this Job.

      ![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/creating_a_drop_down_list2.png)
6. Configure the tMysqlInput to query the people information from the employee table:
   1. ![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/creating_a_drop_down_list4.png)in the Query box, use a context variable to select the information of the employee chosen by the user at runtime,
      ```
      "select * from employee where name='"+context.name+"'"
      ```
   2. in the Edit Schema dialog box, define the data structure of the employee table.

      ![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/creating_a_drop_down_list3.png)
7. Double-click tLogRow and configure its settings to print the results on Talend Studio.
8. Execute the Job, and select one of the names from the drop-down list when prompted.

   ![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/creating_a_dynamic_drop_down_list3.png)
9. For example, select Stephane from the list. The information is queried from the table and printed on the console.

   ![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/creating_a_drop_down_list6.png)