• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            elva

            Ajax方式的留言板

            ajax.js

            //************************  建立XML對象  **********************

            function InitAjax(){
                var http_request = false;
                if (window.XMLHttpRequest){
                    http_request = new XMLHttpRequest();
                    if (http_request.overrideMimeType){
                        http_request.overrideMimeType('text/html;charset=utf-8');
                    }
                }else if (window.ActiveXObject){
                    try{
                        http_request = new ActiveXObject("Msxml2.XMLHTTP");
                    }
                    catch (e){
                        try{
                            http_request = new ActiveXObject("Microsoft.XMLHTTP");
                        }catch (e)
                        {}
                    }
                }
                if (!http_request){
                    alert('Giving up :( Cannot create an XMLHTTP instance');
                    return false;
                }
                return http_request;
            }

            //*************************   提交留言   ***************************//
            function leaveword(fcode,fflag,fpid,fpage){
             var str = '';
            // if(fpid==''){alert('參數錯誤!\n\n請刷新本頁后重新提交!');return false;}
             var url = "leaveword.asp?pid=";
             url=url+fpid+'&page='+fpage;//定義網址參數
             if(fflag!='add'){
            //  url=url+fpid+'&page='+fpage;//定義網址參數
             }
             else{
              var content=document.getElementById("content").value;
              document.getElementById("content").value='';
              if(content==''){alert('您還沒有添寫留言內容!');return false;}
              if(content.length>150){alert('留言內容過長!');return false;}
              url+='&content='+content+'&flag='+fflag;
              str = '數據已提交。';
             }
             str+='正在讀取留言...';
             document.getElementById('msglist').innerHTML='';
             document.getElementById('msg').innerHTML=str;
             xmlhttp_request=InitAjax();//調用創(chuàng)建XMLHttpRequest的函數
             xmlhttp_request.open('GET', url, true);
             xmlhttp_request.onreadystatechange = function(){
              if (xmlhttp_request.readyState == 4) {
               if (xmlhttp_request.status == 200) {
                var result = xmlhttp_request.responseBody;
                document.getElementById('leaveword').innerHTML = gb2utf8(result);
               }
               else
               {
                var str10 = '<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0"><tr>';
                str10 += '<td><div class="bmbkbc"><table width="100%" border="0" cellspacing="0" cellpadding="0">';
                str10 += '<tr><td height="30" align="center" bgcolor="#FEFAF1"><span class="BMSTYLE4" id="msg">數據讀取錯誤,請刷新本頁查看留言內容!</span></td>';
                str10 += '  </tr></table></div></td>      </tr>    </table>';
                document.getElementById('leaveword').innerHTML = str10;
               }
              }
             }
             xmlhttp_request.send(null);
            }
            //*********************  轉換亂碼函數  ****************************
            function gb2utf8(data){ 
                var glbEncode = []; 
                gb2utf8_data = data; 
                execScript("gb2utf8_data = MidB(gb2utf8_data, 1)", "VBScript"); 
                var t=escape(gb2utf8_data).replace(/%u/g,"").replace(/(.{2})(.{2})/g,"%$2%$1").replace(/%([A-Z].)%(.{2})/g,"@$1$2"); 
                t=t.split("@"); 
                var i=0,j=t.length,k; 
                while(++i<j) { 
                    k=t[i].substring(0,4); 
                    if(!glbEncode[k]) { 
                        gb2utf8_char = eval("0x"+k); 
                        execScript("gb2utf8_char = Chr(gb2utf8_char)", "VBScript"); 
                        glbEncode[k]=escape(gb2utf8_char).substring(1,6); 
                    } 
                    t[i]=glbEncode[k]+t[i].substring(4); 
                } 
                gb2utf8_data = gb2utf8_char = null; 
                return unescape(t.join("%")); 

             

            Leaveword.asp

             

            <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
            <body>
            <!-- #include file="conn.asp" -->
            <%
            Response.buffer=true
            Response.Expires = -1
            Response.AddHeader "Pragma","no-cache"
            Response.AddHeader "cache-ctrol","no-cache"

            function GetConn(cityName)
             Set dbConnLocal = Server.CreateObject("ADODB.Connection")
             ConnSQL = ""
             select case Lcase(cityName)
                   Case "test"
                      ConnSQL = "driver={sql server};database=test;server=.;uid=sa;pwd="    
             end select
             dbConnLocal.open ConnSQL
             set GetConn = dbConnLocal
            end function

            Set Conn = GetConn("test")
            Set Rs = Server.CreateObject("ADODB.RecordSet")
            s_Flag = Replace(Request.QueryString("flag"),"'","")
            s_Content = Replace(Request.QueryString("Content"),"'","''")
            s_ProgramID = Replace(Request.QueryString("PID"),"'","")
            s_UserName = Request.Cookies("UserName")
            If s_UserName = "" Then
             s_UserName = "游客"
            End If
            UserIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
            If UserIP = "" Then UserIP = Request.ServerVariables("REMOTE_ADDR")

            If UCase(s_Flag) = "ADD" Then
             If s_Content = "" Or Len(s_Content) > 150 Or s_ProgramID = "" Or Not IsNumeric(s_ProgramID) Then
              Response.Write("Error2")
              Response.End()
             End If
             Sql = "Insert Into T_LeaveWord(ProgramID,UserName,IP,Content) Values('"&s_ProgramID&"','"&s_UserName&"','"&UserIP&"','"&s_Content&"')"
             Conn.Execute Sql
            End If
            Sql = "Select * From T_LeaveWord Where ProgramID='"&s_ProgramID&"' Order By DateTime Desc"
            Rs.Open Sql,Conn,1,3
            m_Page = Trim(Request("Page"))
            If m_Page = "" Or Not IsNumeric(m_Page) Then m_Page = 1
            n = 10
            i = 1
            Rs.PageSize  = n
            mRecordCount = Rs.RecordCount
            mPageCount  = Rs.PageCount
            If Rs.Eof And Rs.Bof Then%>
             <table width="100%" height="30" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td><div class="bmbkbc"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td height="30" align="right" bgcolor="#FEFAF1"><span class="BMSTYLE4" id="msg">本頁有0條評論0</script></span></td>
              </tr>
            </table>
            </div></td>
                  </tr>
                </table><div id="msglist"></div>
            <%Else
             If Cint(m_page) < 1 Or Cint(m_page) > mPageCount then
              m_page = 1
             End If
             Rs.AbsolutePosition = n*(Cint(m_Page)-1)+1%>
             <table width="100%" height="30" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td><div class="bmbkbc"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td height="30" align="right" bgcolor="#FEFAF1"><span class="BMSTYLE4" id="msg">總共有<%=mRecordCount%>條評論,第<%=m_page%>頁 <%
            If m_page <> 1 Then%>
              <A title=首頁 href="javascript:leaveword('','','<%=Rs("ProgramID")%>',1);">|&lt;</A>
            <%End If
            If m_page > 5 Then
             If (m_page Mod 5) = 0 Then
              i_Flag = m_page - 4
             Else
              i_Flag = m_page - (m_page Mod 5) + 1
             End If%>
              <A title=上5頁 href="javascript:leaveword('','','<%=Rs("ProgramID")%>',<%=i_Flag - 1%>);">&lt;</A>
            <%Else
             i_Flag = 1
            End If
            For i = i_Flag To mPageCount
             If i = CInt(m_page) Then%>
              <font color=red><%=i%></font>
            <% Else%>
              <A href="javascript:leaveword('','','<%=Rs("ProgramID")%>',<%=i%>);"><%=i%></A>
            <% End If
             If (i Mod 5) = 0 Then
              Exit For
             End If
            Next
            If i < mPageCount Then%>
              <A title=下5頁 href="javascript:leaveword('','','<%=Rs("ProgramID")%>',<%=i + 1%>);">&gt;</A>
            <%
            End if
            If CInt(m_page) <> CInt(mPageCount) And CInt(mPageCount) > 1 Then%>
              <A title=尾頁 href="javascript:leaveword('','','<%=Rs("ProgramID")%>',<%=mPageCount%>);">&gt;|</A>
            <%End If%> </span></td>
              </tr>
            </table>
            </div></td>
                  </tr>
                </table><div id="msglist">
            <% i = 1
             While Not Rs.Eof And i <= n
              If (i Mod 2) = 0 Then
               s_Color = "#FFFFFF"
              Else
               s_Color = "#F6F6F6"
              End if%>
             <div class="bmbk2">
               <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#DFDFDF" bgcolor="<%=s_Color%>">
                    <tr>
                      <td height="80" valign="top"><div class="bmbk3"><div>
                  <p align="left"><strong>&nbsp;</strong><span class="BMSTYLE1"><strong>[<%=Rs("UserName")%>]</strong></span> <span class="BMSTYLE4">留言 說:</span></p>
                </div>
                <div class="bmSTYLE7Copy">
                          <div align="left">&nbsp;&nbsp;<%=ReplaceImg(Rs("Content"))%></div>
                        </div>
               <br>
               <div>
                          <div align="right"><span class="bmbkk">發(fā)表時間:<%=Rs("DateTime")%> </span></div>
                        </div></div></td>
                    </tr>
                  </table>
             </div>
            <%  i = i + 1
              Rs.MoveNext
             Wend
            End If
            Rs.Close:Set Rs = Nothing
            Conn.Close:Set Conn = Nothing
            %>
            </div>
            </body>

             

            index.htm

            <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
            <html>
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
            <title>無標題文檔</title>
            </head>
            <script src="ajax.js"></script>
            <body>
            <textarea id="content" name="content" cols="60" rows="8" wrap="physical" class="BMSTYLE4"></textarea>
            <INPUT style="HEIGHT: 24px" type=button onclick="leaveword('<%=Session("GetCode")%>','add','<%=i_ID%>',1);" value=提交評論><br>
            <div id="leaveword"><table width="100%" height="30" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td><div class="bmbkbc"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td height="30" align="center" bgcolor="#FEFAF1"><div class="BMSTYLE4" id="msg">正在讀取留言...</div></td>
              </tr>
            </table>
            <div id="msglist"></div>
            </div></td>
                  </tr>
                </table>
            <script language="javascript">leaveword('','','<%=i_ID%>',1);</script>
            </div>
            </body>
            </html>

            posted on 2007-05-28 19:49 葉子 閱讀(643) 評論(1)  編輯 收藏 引用 所屬分類: Ajax

            Feedback

            # re: Ajax方式的留言板 2010-04-20 11:41 DYYY

            [ url = http://www.168sheji.com/c14455/]標志設計[ /url ]
            [ url = http://www.168sheji.com/]畫冊設計[ /url ]
            [ url = http://www.168sheji.com/]設計公司[ /url ]
            [ url = http://www.168sheji.com/c14455/] LOGO設計[ /url ]
            [ url = http://www.168sheji.com/]畫冊設計[ /url ]
              回復  更多評論   

            亚洲人成网站999久久久综合| 久久久久人妻精品一区三寸蜜桃 | 精品久久久久久无码国产| 久久九九久精品国产免费直播| 国内精品久久久久影院网站 | 久久久久久精品免费免费自慰 | 少妇久久久久久被弄到高潮| 久久精品蜜芽亚洲国产AV| 亚洲v国产v天堂a无码久久| 欧美喷潮久久久XXXXx| 一级女性全黄久久生活片免费| 国内高清久久久久久| 久久精品国产男包| 办公室久久精品| 国产福利电影一区二区三区久久久久成人精品综合 | 国产精品成人99久久久久91gav| 99久久伊人精品综合观看| 久久精品免费一区二区| 久久精品这里只有精99品| 久久精品人人槡人妻人人玩AV | 99久久精品免费看国产一区二区三区| 久久亚洲国产欧洲精品一| 精品久久久久久无码人妻热| 一本色综合久久| 欧美一级久久久久久久大| 91精品国产综合久久四虎久久无码一级| 色综合久久久久综合体桃花网| 人妻精品久久无码专区精东影业 | 奇米影视7777久久精品人人爽 | 国产精品99久久99久久久| 久久99精品久久久久婷婷| 久久久黄色大片| 亚洲中文久久精品无码ww16| 久久99精品国产99久久| 亚洲中文字幕无码久久2020| 亚洲午夜无码久久久久| 久久一区二区免费播放| 性高朝久久久久久久久久| 国产激情久久久久影院老熟女| 一级做a爰片久久毛片16| segui久久国产精品|