0

我是 jQuery 和 AJAX 的初学者,我只想从 JSP 文件中获取一个值到 HTML5,这样我就可以将该值放入<textarea>我的 HTML5 源代码中的 a 中。请帮助我,谢谢。
这是源文件:

<html>
..
 <body>
<div data-role="content">
<div data-role="fieldcontain"> 
    <form method="post" action="ShowQuestion.jsp" name="frm" > <!--using post action, transfer Element Information-->   
<label for="theQuestion"></label>
 <div id="QuestionLog"> <!--to contain my question title and content-->
   <input type="text" id="qnaTitle" name="qnaTitle" > </input> <!--input title-->
<textarea cols="20" rows="5" wrap="hard" id="qnaContent" name="qnaContent">
 </textarea> <!--input content-->
     </div>       
   </form>
..
</body>
</html>

Connection conn;
PreparedStatement pstmt;
ResultSet rs=null;

pstmt = conn.prepareStatement("select * from question "); // query
rs = pstmt.executeQuery(); // execute that query 

while(rs.next()) {

   String title=rs.getString(1); //save the query's result      
   String content = rs.getString(2);  //save the query's result,too

}
}catch(Exception e) {

   e.printStackTrace(); // print the Exception Message

}
4

1 回答 1

0

当您使用 jquery 时,在获得值(并且您确定)之后,您所要做的就是

$('#qnaContent').val(content); // Considering that the result string is stored in "content"
于 2013-02-08T12:58:26.240 回答