未捕获的ReferenceError:函数未在HTMLbuttonelement.onclick上使用onClick定义

时间:2017-11-22 16:01:17

标签: javascript java jsp

当我尝试点击按钮时我有一个错误,我已经尝试了很多来自stackoverflow的解决方案,但这些解决方案似乎都不起作用

<button type="button" onclick="getZawartosc();">Basic</button>

出错

this is error from console

我的源文件

<%@ page import="java.sql.*" %>
<%@ page import="com.microsoft.sqlserver.jdbc.*" %>
<%ResultSet resultset =null;%>

<HTML>
<HEAD>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</HEAD>

<BODY BGCOLOR=##f89ggh>
<div>

<%
    try{

String hostName = "xxxxx";
String dbName = "xxxxx";
String user = "xxxxx";
String password = "xxxxx";
String url = String.format("jdbc:sqlserver://%s:1433;database=%s;user=%s;password=%s;encrypt=true;hostNameInCertificate=*.database.windows.net;loginTimeout=30;", hostName, dbName, user, password);
Connection connection = null;   
connection = DriverManager.getConnection(url);

Statement statement = connection.createStatement() ;

       resultset =statement.executeQuery("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_CATALOG='malarzeBaza'") ;
%>

<left>
    <h1> Drop down box or select element</h1>
        <select>
        <%  while(resultset.next()){ %>
            <option><%= resultset.getString(1)%></option>
        <% } %>
        </select>
</left>
<center>
<button type="button" onclick="getZawartosc();">Basic</button>
</center>



<script type="text/javascript">
function getZawartosc(){
    <%
    resultset =statement.executeQuery("SELECT * FROM dbo.Malarze") ;
    %>
    console.log(<%resultset.getString(2);%>);


}
</script>
<%
//**Should I input the codes here?**
        }
        catch(Exception e)
        {
             out.println("wrong entry"+e);
        }
%>

</BODY>
</HTML>

0 个答案:

没有答案