js调用Cookie;对Table调用

来源:互联网 发布:linux查看服务器型号 编辑:程序博客网 时间:2024/06/15 03:59

 <script type="text/javascript">
    var xmlhttp;
        function ShowDates(){
            document.getElementById('<%= lblActionDate.ClientID %>').style.display = 'none';
            document.getElementById('<%= dateMore.ClientID %>').style.display = '';
            document.getElementById('<%= imgDown.ClientID %>').style.display = 'none';           
        }
       
        function setCookie(arg_CookieName,arg_CookieValue,arg_CookieExpireDays)
            {
                var todayDate=new Date();
                todayDate.setDate(todayDate.getDate()+arg_CookieExpireDays);
                document.cookie=arg_CookieName+'='+arg_CookieValue+';path=/;expires='+todayDate.toGMTString();
                alert(document.cookie);
            }
       
        function getCookie(cookie_name)
        {
            var allcookies = document.cookie;
            var cookie_pos = allcookies.indexOf(cookie_name);

            if (cookie_pos != -1)
            {
                cookie_pos += cookie_name.length + 1;
                var cookie_end = allcookies.indexOf(";", cookie_pos);

                if (cookie_end == -1)
                {  
                    cookie_end = allcookies.length;
                }

                var value = allcookies.substring(cookie_pos, cookie_end);
            }
             return value;
         }

        function CheckOk(i)
        {
            var days =10;
            var ticketsinfo;
            var count = document.getElementById(i).value==''?"1":document.getElementById(i).value;
            var id=i.substring(9,13);
            var str = id+'-'+count;
            var cookieId = getCookie('TCTICKETCART');
            if(cookieId != '' && cookieId != null)
            {
                ticketsinfo =cookieId + ","+ str;
            }
            else
            {
                ticketsinfo ="TCFlat=1&tickets="+ str;
            }
           
            setCookie("TCTICKETCART",ticketsinfo,days);
           
            window.location.href='ticket-book1.aspx';
        }
       
        function statechange()
                {
                    if(xmlhttp.readystate==4)
                    {
                     if(xmlhttp.status==200)
                        {
                        document.getElementById("ShowInfo").innerHTML=xmlhttp.responseText;
                        }
                    }
                 }
                
        function CheckDate()
        {
            document.getElementById('lblInfos').style.display='none';
            var ComeDate = document.getElementById('txtComeDate').value;
            var LeaveDate = document.getElementById('txtLeaveDate').value;
            var id = document.getElementById('<%= HiddenField1.ClientID %>').value;
            var tempBeginTime=ComeDate.replace(reg,"//");
            var tempEndTime=LeaveDate.replace(reg,"//");
            if(Date.parse(new Date(tempBeginTime))>=Date.parse(new Date(tempEndTime)))
            {
                 alert("开始日期不能大于或等于结束日期");
                 return;
            }
            else
            { 
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                xmlhttp.onreadystatechange=statechange;
                var url="ticket-infoServer.aspx?id=" +escape(id)+"&comeDate="+escape(ComeDate)+"&leaveDate="+escape(LeaveDate);
                 xmlhttp.Open("GET",url,true);
                xmlhttp.Send();
             }
        }
    </script>

 

 

 

#region 初始化
    protected void Page_Load(object sender, EventArgs e)
    {
        id = Request["id"];
        comeDate = Request["ComeDate"];
        leaveDate = Request["LeaveDate"];

        string sqlString = string.Empty;//
        DateTime aStartDate = Convert.ToDateTime(comeDate);
        DateTime aEndDate = Convert.ToDateTime(leaveDate);
        sqlString = " and StartDate >= '" + aStartDate + "' and EndDate<='" + aEndDate + "'";
        IList<TicketPrice> prices = CacheFileByIList<TicketPrice>(DbReader.CreateQuery("From TicketPrice Where TickInfoId=" + id + sqlString + " And Flag>0 Order By StartDate Asc,PriceOrigin Asc"), "TicketPrice//", 120);
        StringBuilder sb = new StringBuilder();
        sb.Append("<table width='560' frame='rhs' style='border-style:solid; border:1px; border-color:#c0cee0;' cellpadding='0' cellspacing='0'>");
        foreach (TicketPrice ticketPrice in prices)
        {
            sb.Append("<tr><td style='width:170px; text-align:left'>");
            sb.Append(ticketPrice.Name);
            sb.Append("</td>");
            sb.Append("<td style='width:60px; text-align:center;color:#ff6600; font-weight:bold;'>");
            sb.Append("¥&nbsp;" + ticketPrice.PriceOrigin);
            sb.Append("</td>");
            sb.Append("<td style='width:60px; text-align:center;color:#ff6600; font-weight:bold;'>");
            sb.Append("¥&nbsp;" + ticketPrice.PriceProtocol);
            sb.Append("</td>");
            sb.Append("<td style='width:70px; text-align:center'>");
            sb.Append(ticketPrice.Flag);
            sb.Append("</td>");
            sb.Append("<td style='width:75px; text-align:center;padding-left:5px;'>");
            sb.AppendFormat("<input id='txtCount_{0}' type='text' name='txtCount' class='txtCount' style='width:50px' />",ticketPrice.Id);
            sb.Append("</td>");
            sb.Append("<td style='width:78px; text-align:center'>");
            //sb.AppendFormat("<a href='javascript:CheckOk(/"txtCount_{0}/");>", ticketPrice.Id);
            sb.AppendFormat("<a href='javascript:CheckOk(/"txtCount_{0}/");'><img border='0' src='/images/zjdp.gif' /></a>", ticketPrice.Id);
            sb.Append("</td></tr>");
        }
        sb.Append("</table>");
        Response.Write(sb.ToString());
    }
    #endregion

原创粉丝点击