How to give java arraylist to javascript function using JSON

前端 未结 1 792
春和景丽
春和景丽 2021-01-28 17:19

I have a table which is created through javascript function which is as below

Now you can see the cell \"VAT5.5\" is empty.there i have to get the database valu

1条回答
  •  走了就别回头了
    2021-01-28 17:32

    <%
                Connection con = null;
                ResultSet rs = null;
                ArrayList ar=new ArrayList();
                String taxgroup;
    
    
                try {
                     DBConnect db = new DBConnect();
                     con = db.getCon();
                     String sql = "select distinct TaxGroup from marketing_database.tax_info";
                     PreparedStatement smt = con.prepareStatement(sql);
                     rs = smt.executeQuery();
    
                     while(rs.next())
                     {
                         taxgroup=rs.getString(1);
    
                            ar.add(taxgroup);
                            System.out.println("Array is" +ar);
                     }
                     int size = ar.size();
    
    
                     System.out.println("size is" +size);
    
                %>
                <%
                con.close();
                smt.close();
                rs.close();
    
                }
                catch(SQLException ex){
                    ex.printStackTrace();
                  }
    
                %>
    
     var cell7 = row.insertCell(6);
    
              var element7 =  document.createElement("select");
              element7.setAttribute('multiple', '');
              var jsArray = [];
              <%for(int i=0;i
                  jsArray.push("<%= ar.get(i)%>");
              <%}%>
    
    
             //   var optarr =  ["vat1","vat2","vat3","vat4","vat5","vat6","vat7","vat8","vat9"];
              alert(jsArray.length);
              alert(jsArray);
              for(var i = 0;i

    0 讨论(0)
提交回复
热议问题