js留言

// JScript 文件
/*
author(dyb);
**/
    var salerId;//销售者ID
    var productId;//产品ID
    var content;//留言内容
    var pageNum;//页数 
   
    function InitPage_CallBack(response)//初始页码响应函数
    {
        var str=response.value;
        var divPage=document.getElementById("divPage");
        divPage.innerHTML=str;       
    }
   
    function AddLeaveWord()//添加留言
    {
        if(GetContent())
        {
             SetValue();
             Uc_Index_LeaveWordUc.AddLeaveWord(salerId,productId,content,AddLeaveWord_CallBack);
        }
    }
   
    function AddLeaveWord_CallBack(response)//添加留言响应函数
    {
        var res=response.value;
  var hfSuccess=document.getElementById("hfSuccess");
  var hfFail=document.getElementById("hfFail");
  var txtContent=document.getElementById("txtContent");
        if(res=="suc")
        {           
            alert(hfSuccess.value);
   txtContent.value='';   
            Uc_Index_LeaveWordUc.GetDataSet(salerId,productId,1,InitList_CallBack);
        }
        else
        {
            alert(hfFail.value);
        }
    }
   
    function GetDataSet(event)//获取数据集,以分页
    {
        var e=event||window.event;
        var el=e.srcElement||e.target;
        SetValue();   
        Uc_Index_LeaveWordUc.GetDataSet(salerId,productId,parseInt(el.id),InitList_CallBack);
    }
   
    function InitList_CallBack(response)//分页,响应函数
    {
        var ds=response.value;
        var divLw=document.getElementById("divLw");
  var hfLeaveWordName=document.getElementById("hfLeaveWordName");
  var hfLwTime=document.getElementById("hfLwTime");
  var hfContent=document.getElementById("hfContent");
        if(ds!=null&&typeof(ds)=="object"&&ds.Tables!=null)
        {
            var dt=ds.Tables[0];
            var lwList='

';
   pageNum=parseInt(dt.Rows[0].pageNum);   
            for(var i=0;i            {               
                lwList+='
'
                      + ''
                      + ''
                      + '';        
            }
            lwList+='';    
            Uc_Index_LeaveWordUc.InitPage(pageNum,InitPage_CallBack);
            divLw.innerHTML=lwList;           
        }
    }
   
    function GetContent()//获取添加的留言,判断不能为空
    {
        var txtContent=document.getElementById("txtContent");
  var hfContentError=document.getElementById("hfContentError"); 
        if(txtContent.value.length<=0)
        {
            alert(hfContentError.value);
            return false;
        }
        content=txtContent.value;
        return true;
    }  
   
    function SetValue()//设置salerId,productId,pageNum的值
    {
        var hfsalerId=document.getElementById('hfsalerid');
  var hfproductId=document.getElementById('hfproductid');
  var hfpageNum=document.getElementById('hfpagenum');
  salerId=parseInt(hfsalerId.value);
  productId=parseInt(hfproductId.value);  
  pageNum=parseInt(hfpageNum.value);
    }   


 window.οnlοad=function(){ 
  SetValue();
  Uc_Index_LeaveWordUc.InitPage(pageNum,InitPage_CallBack);}//载入时初始总页数,并且初始页码列表

 

你可能感兴趣的:(js留言)

'+hfContent.value+dt.Rows[i].content+''+hfLeaveWordName.value+dt.Rows[i].leavewordname+'
'
                      + hfLwTime.value+dt.Rows[i].inputdate+'