-I need to place multiple values in a listbox (values should be extracted from a table in a mysql database) -The idea is that after making the query to the database, in the label of listitem: the name must be of value, and the value: the id of the field. The id field I need to then save it and insert it into another table with other fields. -This should appear immediately load the form.
Good afternoon
I require your help please.
-I need to place multiple values in a listbox (values should be extracted from a table in a mysql database)
-The idea is that after making the query to the database, in the label of listitem: the name must be of value, and the value: the id of the field. The id field I need to then save it and insert it into another table with other fields.
-This should appear immediately load the form.
Any ideas please, thank you very much.
Here is some code that until now I'm building:
<row> <label value="Sexo:" width="150px" /> <hlayout> <listbox id="idsexo" mold="select" rows="1" width="150px" onSelect=""> <listitem label="Femenino" value="1" selected="true"/> <listitem label="Masculino" value="2"/> <attribute name="onSelect"> <![CDATA[ import java.sql.*; import java.util.*; import javax.sql.*; import javax.naming.InitialContext; import java.lang.*; DataSource ds = (DataSource) new InitialContext() .lookup("java:comp/env/jdbc/planeta-docs"); PreparedStatement stmt = null; Connection conn = null; conn = ds.getConnection(); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT idsexo, strNombre FROM sexo"); row = rs.executeQuery Int value = (Int) row.getValue(1); String label = (String) row.getValue(2); ]]> </attribute> </listbox> </hlayout> </row>