问题1:有连续的多个页面,要将每个页面的某些值保存在cookie中,这些值可能有中文字符,也可能有英文字符。
问题2:将问题1中写入的cookie读出来,要求是将这些全部的cookie读出来并保存在一个数组中,并将这个数组与已存在的某个数组做比较,得到其相同的值有多少。
问题3:以上的问题1和问题2循环多次以后,将最后的4次以报表的形式显示出来。例:类别   进行日期     课题      xxx       xxx    
   111    2007.03.21   aaa        20        20      
   222    2007.03.21   aaa        20        20       
   111    2007.03.21   aaa        20        20       
   222    2007.03.21   aaa        20        20      

解决方案 »

  1.   

    希望最好能给出代码,因为本人的JavaScript脚本技术实在是很差的。
      

  2.   

    Cookie操作:
    function SetCookie(sName,sValue){
    var Days = 30;
    var exp  = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = sName + "=" + escape(sValue) + "; path=/; expires=" + exp.toGMTString();
    }
    function GetCookie(sName){
    var aCookie = document.cookie.split("; ");
    for(var i=0;i<aCookie.length;i++){
    var aCrumb = aCookie[i].split("=");
    if(sName == aCrumb[0]){
    return unescape(aCrumb[1]);
    }
    }
    return null;
    }
      

  3.   


    <html>
    <head>
    <meta http-equiv="Content-Language" content="en" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>title</title>
    </head>
    <body bgcolor="#FFFFFF" text="#000000" link="#FF9966" vlink="#FF9966" alink="#FFCC99">  <script language="JavaScript" type="text/javascript">
       function getDiv()
       {
       alert(document.getElementById('myapp').Text)
       }
      
       function saveIt(name,value)
       {
    document.cookie = name + "=" + value + ";" ;
    alert("created...");
    }
    function readIt(name){
    var allCookie = document.cookie.split("; ");
    for(var i=0;i<allCookie.length;i++){
    var tmparry = allCookie[i].split("=");
    if(name == tmparry[0]){
        alert(tmparry[1]);
    }
    }


    }
    </script>  <input type="button" name="create" onclick="saveIt('name','test');" value="create name cookie"/>
      <input type="button" name="create" onclick="saveIt('age',11);" value="create age cookie"/>
      <input type="button" name="create" onclick="saveIt('sex','male');" value="create sex cookie"/>
        
      <input type="button" name="create" onclick="readIt('name');" value="read name cookie"/>
      <input type="button" name="create" onclick="readIt('age');" value="read age cookie"/>
      <input type="button" name="create" onclick="readIt('sex');" value="read sex cookie"/> 
      
    </body>
    </html>
      

  4.   

    因为当我的页面跳转时,在新的页面我又要写入cookie,此时会不会丢失以前写的cookie呢?
    每个页面我至少会写入2个cookie值,至少有10个连续的页面,然后将所有的cookie写成一个字符串,去和已有的一个字符串做比较。
      

  5.   

    写进去cookie是没问题的,就是读的时候很麻烦啊,如果写了10个cookie,我就要做在最后的比较页面预先准备10个字符串,然后每个做对应的比较,这样取的很麻烦,谁有高招,最好取和比较一次就搞完了。