• <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對(duì)象  **********************

            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('參數(shù)錯(cuò)誤!\n\n請(qǐng)刷新本頁(yè)后重新提交!');return false;}
             var url = "leaveword.asp?pid=";
             url=url+fpid+'&page='+fpage;//定義網(wǎng)址參數(shù)
             if(fflag!='add'){
            //  url=url+fpid+'&page='+fpage;//定義網(wǎng)址參數(shù)
             }
             else{
              var content=document.getElementById("content").value;
              document.getElementById("content").value='';
              if(content==''){alert('您還沒(méi)有添寫留言內(nèi)容!');return false;}
              if(content.length>150){alert('留言內(nèi)容過(guò)長(zhǎng)!');return false;}
              url+='&content='+content+'&flag='+fflag;
              str = '數(shù)據(jù)已提交。';
             }
             str+='正在讀取留言...';
             document.getElementById('msglist').innerHTML='';
             document.getElementById('msg').innerHTML=str;
             xmlhttp_request=InitAjax();//調(diào)用創(chuàng)建XMLHttpRequest的函數(shù)
             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">數(shù)據(jù)讀取錯(cuò)誤,請(qǐng)刷新本頁(yè)查看留言內(nèi)容!</span></td>';
                str10 += '  </tr></table></div></td>      </tr>    </table>';
                document.getElementById('leaveword').innerHTML = str10;
               }
              }
             }
             xmlhttp_request.send(null);
            }
            //*********************  轉(zhuǎn)換亂碼函數(shù)  ****************************
            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">本頁(yè)有0條評(píng)論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%>條評(píng)論,第<%=m_page%>頁(yè) <%
            If m_page <> 1 Then%>
              <A title=首頁(yè) 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頁(yè) 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頁(yè) href="javascript:leaveword('','','<%=Rs("ProgramID")%>',<%=i + 1%>);">&gt;</A>
            <%
            End if
            If CInt(m_page) <> CInt(mPageCount) And CInt(mPageCount) > 1 Then%>
              <A title=尾頁(yè) 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">留言 說(shuō):</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ā)表時(shí)間:<%=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>無(wú)標(biāo)題文檔</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=提交評(píng)論><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 葉子 閱讀(639) 評(píng)論(1)  編輯 收藏 引用 所屬分類: Ajax

            Feedback

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

            [ url = http://www.168sheji.com/c14455/]標(biāo)志設(shè)計(jì)[ /url ]
            [ url = http://www.168sheji.com/]畫冊(cè)設(shè)計(jì)[ /url ]
            [ url = http://www.168sheji.com/]設(shè)計(jì)公司[ /url ]
            [ url = http://www.168sheji.com/c14455/] LOGO設(shè)計(jì)[ /url ]
            [ url = http://www.168sheji.com/]畫冊(cè)設(shè)計(jì)[ /url ]
              回復(fù)  更多評(píng)論   

            丁香五月综合久久激情| 久久精品国产亚洲AV无码麻豆 | 青青草国产精品久久久久| 中文字幕久久久久人妻| 香港aa三级久久三级老师2021国产三级精品三级在| 久久人人爽人人爽人人片av麻烦| 精品综合久久久久久97超人| 久久精品国产亚洲AV电影| 午夜精品久久久久久久| 无码专区久久综合久中文字幕| 久久精品中文字幕一区| 91麻豆国产精品91久久久| 午夜精品久久久久久久| 久久国产热精品波多野结衣AV| 亚洲精品无码久久千人斩| 久久综合给合久久狠狠狠97色| 久久99国产综合精品免费| 国产精品对白刺激久久久| 久久免费视频观看| 久久综合久久性久99毛片| 久久久久亚洲AV成人网人人网站| 色婷婷久久久SWAG精品| 久久人做人爽一区二区三区| 久久精品午夜一区二区福利| 日韩精品国产自在久久现线拍| 久久影视国产亚洲| 亚洲午夜无码久久久久| 欧美亚洲另类久久综合| 国内高清久久久久久| 久久精品中文字幕久久| 武侠古典久久婷婷狼人伊人| 久久国产欧美日韩精品| 久久影视国产亚洲| 国产成人精品久久免费动漫 | 国内精品欧美久久精品| 国产69精品久久久久APP下载| 国产精品久久久久jk制服| 亚洲国产成人久久综合区| 国产精品久久久久久影院| 漂亮人妻被中出中文字幕久久| 久久精品国产亚洲一区二区|