如何使用复选框动态填充下拉列表并在jsp

时间:2015-12-17 15:48:59

标签: javascript java json jsp jdbc

我已经从数据库中获取了数据,并且我必须再次获取相同的表格和相同的对应id,其中referencedComponentId =? 。为此,如果我单击按钮,它会显示动态下拉复选框,我必须选中一个复选框并提交。再次提交后,从表中获取一行。下面的代码将从表中获取数据,我打破了如何使用复选框填充下拉列表并提交,这是我的代码

<%!public class Code {
        String url = "jdbc:mysql://localhost:3306/snomedtoicd10";
        String username = "root";
        String password = "root";

        Connection connection = null;
        PreparedStatement pstm = null;
        ResultSet resultSet = null;

        public Code() {

            try {
                connection = DriverManager.getConnection(url, username,
                        password);
                String sql = "select * from snomedcsvotherwise where referencedComponentId=? ";
                pstm = connection.prepareStatement(sql);
           // AND `mapRule` LIKE '%TRUE%'
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        public ResultSet getCode(String Snomedcode) {

            try {
                pstm.setString(1, Snomedcode);
                resultSet = pstm.executeQuery();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            return resultSet;
        }
    }%>

    <%
        String snomedcode = new String();

        String str = request.getParameter("snomedcode");
        if (str != null) {
            snomedcode = str;
        }
        Code c = new Code();
        ResultSet codes = c.getCode(snomedcode);    
    %>

    <h2 align="center">
        <font><strong>SNOMED CODE TO ICD 10 CODE</strong></font>
    </h2>

    <div style='min-height:40px'>
    <table id="tblMain" width="100%" class='table1' border=0 cellpadding='5' cellspacing='0' style='topmargin:-5px'>

    <tr class='headerText' style='height:25px'>
        <td class='tdcellblue' style='width: 10%'>SNOMED</td>
        <td class='tdcellblue' style='width: 40%'>SNOMED Name</td>
        <td class='tdcellblue' style='width: 10%'>ICD-10</td>
        <td class='tdcellblue' style='width: 40%'>ICD Name</td>
    </tr>
        <%
            while (codes.next()) {
                String maprule = null;
                maprule=(codes.getString("mapRule"));
                if(maprule.matches("OTHERWISE TRUE") || maprule.matches("TRUE"))
                {
        %>

        <tr >
            <td><%=codes.getString("referencedComponentId")%></td>
            <td><%=codes.getString("sctName")%></td>
            <td><%=codes.getString("mapTarget")%></td>
            <td><%=codes.getString("icdName")%></td>
        </tr>

    <%}%>

    <%}%>

0 个答案:

没有答案