用XMLHTTP無刷新頁面的javascript寫法9/30

做了一個頁面:包含用來選擇幣別的dropdownlist和用來顯示匯率的textbox,當點選幣別時,可通過如下xmlhttp方法在無刷新頁面的情況下去抓取匯率值:

1<asp:dropdownlist font-names="新細明體" font-size="9pt" forecolor="Blue" id="ddl1" onchange="rat(this.value,document.forms[0].TextBox23);  " runat="server" tabindex="13" width="65px"></asp:dropdownlist>

function rat(obj,obq) { var xh=new ActiveXObject("Microsoft.XMLHTTP"); xh.open("POST","rate.aspx?ckind=" + obj,false); xh.send(); //alert(bytes2BSTR ( xh.responseBody)); //alert(xh.responseText); obq.value = xh.responseText; }

所做的 rate.aspx的html 頁面只有兩行: ``` @ Page Language="vb" AutoEventWireup="false" Codebehind="rate.aspx.vb" Inherits="GBys.rate"

rate()

1
2參考資料:http://www.gamvan.com/web/aspx/2005/7/580.html 
3
4P.S.在此也感謝一位網友的熱心幫助!
Published At
Categories with Web编程
Tagged with
comments powered by Disqus