2017-05-07 103 views
0

我想在jsp中的文本字段中顯示值。我已經從jsp頁面的數據庫中提取了值,現在我想在文本字段中顯示onblur方法調用。我們如何顯示jsp文本字段中的值

<%!Connection con; %> 
<%!Statement s; %> 
<%!ResultSet rs; %> 
<% String cnic=request.getParameter("id"); 
try{ 
Class.forName("com.mysql.jdbc.Driver"); 
con=DriverManager.getConnection("jdbc:mysql://localhost/test","root",""); 
s=con.createStatement(); 
rs=s.executeQuery("select * from info where cnic='"+cnic+"'"); 
}catch(Exception e){ e.printStackTrace(); } 
%> 

<% while(rs.next()) 
{ %> 

<%=rs.getString("first_name")%> 
<%=rs.getString("last_name")%> 
<%=rs.getString("gender")%> 
<%=rs.getString("cnic")%> 
<%=rs.getString("date_of_birth")%> 
<%=rs.getString("institute")%> 
<%=rs.getString("department")%> 
<%=rs.getString("degree_level")%> 
<%=rs.getString("programe")%> 
<%=rs.getString("year")%> 

<% } %> 

    <input type="text" onblur="Ajax(this.value);" /> 
    <input type="text" /> 
    <input type="text" /> 

我們如何在這些文本字段顯示值

回答

0

只要做到這一點

<input type="text" value="<%=yourExpression%>"/> 
+0

它不工作,因爲在上面的,我們不能訪問了循環 – muneeb

+0

的循環結束那麼究竟什麼是你試圖做什麼?您是否試圖爲每個結果集行顯示一組框或一組框? 請添加更多解釋。 – amahfouz

相關問題