日期:2014-05-16 浏览次数:20634 次
<script type="text/javascript" language="javascript"> var xmlHttp; //创建XHR function createXmlHttpRequest() { //非IE if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); if (xmlHttp.overrideMimeType) { xmlHttp.overrideMimeType("text/xml"); } } //IE else if (window.ActiveXObject) { try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } } if (!xmlHttp) { window.alert("你的浏览器不支持创建XMLhttpRequest对象"); } return xmlHttp; } //实现 function addNumber() { var a = document.getElementById("tb1").value; var b = document.getElementById("tb2").value createXmlHttpRequest(); var url = "test1.asp?a1=" + a + "&a2=" + b;//发送请求的页面。在该页面返回所需的 xmlHttp.open("GET",url,true);//打开 xmlHttp.onreadystatechange = showResult;//处理 xmlHttp.send(null); } //处理过程 function showResult() { if (xmlHttp.readyState == 4) { if (xmlHttp.status == 200) { document.getElementById("tb3").value = xmlHttp.responseText; } else if(xmlHttp.status == 404) { alert(xmlHttp.responseText); } } } </script> <form id="form1"> <div> <table> <tr><td><p>加法运算:</p></td></tr> <tr> <td><input type="text" id="tb1" name="tb1" value="0" onkeyup="addNumber()" /></td> <td>+</td> <td><input type="text" id="tb2" name="tb2" value="0" onkeyup="addNumber()" /></td> <td>=</td> <td><input type="text" id="tb3" name="tb3" /></td> </tr> </table> </div> </form>
<% aa = Request.QueryString("a1") bb = Request.QueryString("a2") cc = cdbl(aa) + cdbl(bb) Response.Write cc %>