function cx()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","chaxun.jsp",true);
xmlhttp.send(); }
按钮的单击事件。
chaxun.jsp从数据库查询,然后显示。
用了这个,单击按钮,一般情况下没啥反应。但是,单击的次数多了,偶尔会突然蹦出来一下我想要的那个查询结果的表,
但是出现的不到1秒又消失了。什么原因呢?
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","chaxun.jsp",true);
xmlhttp.send(); }
按钮的单击事件。
chaxun.jsp从数据库查询,然后显示。
用了这个,单击按钮,一般情况下没啥反应。但是,单击的次数多了,偶尔会突然蹦出来一下我想要的那个查询结果的表,
但是出现的不到1秒又消失了。什么原因呢?
<form>
<table background="image/toubu.jpg" width="100%" height="50" border="1">
<tr >
<td></td>
</tr>
</table>
<table background="image/erji.jpg" width="100%" height="25">
<tr>
<td>
<font size="2">
您好,欢迎光临! 当前时间: <%Date now=new Date(); out.print(now.toLocaleString()); %>
</font>
</td>
</tr>
</table>
<table background="image/kuang.jpg" width="100%" height="23">
<tr >
<td>
</td>
<td width="70"></td> <td>
<input type="image" src="image/btadd.jpg" height="18" onclick="btclick()"/>
</td>
<td width="70"></td>
<td>
<input type="image" src="image/btliulan.jpg" height="18" onclick="liulan()">
</td>
<td width="70"></td>
<td>
<input type="image" src="image/btchazhao.jpg" height="18" >
</td>
<td width="70"></td>
<td>
<input type="image" src="image/btyonghu.jpg" height="18" >
</td>
<td width="70"></td>
<td>
<input type="image" src="image/btbangzhu.jpg" height="18" >
</td>
<td width="300"></td>
<td>
<input type="image" src="image/bttuichu.jpg" height="18" onclick="clicktc()">
</td>
<td width="100"></td>
</tr>
</table>
</form>
<form>
<table >
<tr>
<td width="800"></td>
<td><input type="text" name="cztext1"></td>
<td><font size="2"><input type="radio" name="r1" value="chazhao1">按学号查找 <input type="radio" name="r1" value="chazhao2">按姓名查找 <input type="submit" value="查 找"></font></td>
</tr>
</table>
</form>
<center>
<table>
<tr>
<td><div id="txtHint">查询信息将在此处列出 ...</div></td>
</tr>
</table>
</center>
<script type="text/javascript">function btclick()
{
window.open('add.jsp', '添加学生信息', 'height=390, width=280, top=150, left=350, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
}
function clicktc()
{
window.close();
}
function liulan()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","chaxun.jsp",true);
xmlhttp.send(); }</script></body>chaxun.jsp<%
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url="jdbc:sqlserver://localhost:1433;DatabaseName=stu";
String username="sa";
String userpwd="sa";
Connection conn=DriverManager.getConnection(url, username, userpwd);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from xsxx";
ResultSet rs=stmt.executeQuery(sql);
rs.first();
out.print("<table border=1>");
out.print("<tr>");
out.print(" <th width=100>学号</th>");
out.print(" <th width=100>姓名</th>");
out.print(" <th width=50>性别</th>");
out.print(" <th width=100>出生日期</th>");
out.print(" <th width=100>籍贯</th>");
out.print(" <th width=100>联系方式</th>");
out.print(" <th width=100>身份证</th>");
out.print("</tr>");
while(rs.next())
{
out.print("<tr>");
out.print("<td>"+rs.getString(1)+"</td>");
out.print("<td>"+rs.getString(2)+"</td>");
out.print("<td>"+rs.getString(3)+"</td>");
out.print("<td>"+rs.getString(4)+"</td>");
out.print("<td>"+rs.getString(5)+"</td>");
out.print("<td>"+rs.getString(6)+"</td>");
out.print("<td>"+rs.getString(7)+"</td>");
out.print("</tr>");
}
out.print("</table>");
%>
这个ajax我没接触过,上午有朋友说让用这个,我就看了看,然后试试,能达到我要的效果,但是就是问题太多。呵呵。。
out.print("</tr>");
}
out.print("</table></form>");
%>
<script type="text/javascript">
function delete1()
{
window.alert(form1.del.id);
}
</script>这个按钮无效了。