你好,欢迎来到电脑编程技巧与维护杂志社! 杂志社简介广告服务读者反馈编程社区  
合订本订阅
 
 
您的位置:技术专栏 / Linux开发
用ASP技术开发WEB调查(投票)系统 (12)
 

 } // doMove()
   
  
     doDelete()函数通过重新编号并压缩这两个数组实现问题的删除(将最后几行去掉):
  
  
   // 确认删除,然后在stemArray[]和ansArray[]中执行删除操作
   function doDelete() {
    if (confirm("是否删除当前显示的问题?")) {
    if (stemArray.length > 0) {
    ID = stemArray[stemIx].substr(0,3); // 被删除问题的ID
    for (i=stemIx; i< stemArray.length-1; i++)
    stemArray[i] = stemArray[i].substr(0,3) +
    stemArray[i+1].substr(3); // 调整删除后的数组内容
    stemArray.length--;
    }
    if (ansArray.length > 0) {
    delCount = 0;
    for (i=0; i< ansArray.length; i++) {
    if (ansArray[i].substr(0,3) == ID) {
    ansArray[i] = "ZZZ"; // 删除该项(排到最后面)
    delCount++;
    } else if (ansArray[i].substr(0,3) > ID) {
    tempID = " " +
    (parseInt(ansArray[i].substr(0,3)) - 1).toString();
    tempID = tempID.substr(tempID.length-3, 3);
    ansArray[i] = tempID + ansArray[i].substr(3);
    }
    }
    ansArray.sort();
    ansArray.length-=delCount;
    }
    doNav("< "); // 尝试退回前一问题
    }
   } // doDelete()
   
  
     doNav()函数支持问题的导航,实现方法是改变需要显示问题的索引号,然后调用writeItem完成输出,代码略。
  
     writeItem是这里最为复杂的函数。它按照问题类型的不同,将HTML代码以字符串的形式输出,这个字符串即为显示与编辑该问题的表单。表单为问题的每个可编辑部件提供了onChange()函数定义。当这个表单被写入页面中间的帧(ItemFrame),用户的编辑操作就会引起对saveStem()或saveAnswer()函数的调用,这些函数负责修改当前调查项目的stemArray[]或ansArray[]数组。
  
  
   // 在浏览器中显示指定的问题
   function writeItem(stemIx) {
    var IType = parseInt(stemArray[stemIx].substr(3,1)); // 问题类型
    var NoOpinion = stemArray[stemIx].substr(4,1); // 是否允许不回答
    var ID = stemArray[stemIx].substr(0,3); // 问题的ID
   
    for (ansIx=0; ansIx< ansArray.length; ansIx++) {
    if (ansArray[ansIx].substr(0,3) == ID) break; // 问题的回答
    }
    if (ansIx >= ansArray.length) ansIx = -1; // 当前问题没有回答结果
    outStr = '< HTML>< BODY BGCOLOR="#c0c0c0">' +
    '< FORM NAME="Item">' +
    '【当前问题编号】' + (stemIx + 1) + '【总问题数】 ' + stemArray.length +
    ' 【调查项目名字】 < %=PollName%>< /B>< BR>< /TABLE>< TEXTAREA NAME="Stem" ROWS=2 COLS=85 '+
    'onBlur="parent.ControlFrame.saveStem()">' +
    stemArray[stemIx].substr(5) + '< /TEXTAREA>< BR>';
   
    if (NoOpinion == "Y" && IType != 5) outStr+=

(编辑:aniston)

  推荐精品文章

·2024年12月目录 
·2024年11月目录 
·2024年10月目录 
·2024年9月目录 
·2024年8月目录 
·2024年7月目录 
·2024年6月目录 
·2024年5月目录 
·2024年4月目录 
·2024年3月目录 
·2024年2月目录 
·2024年1月目录
·2023年12月目录
·2023年11月目录

  联系方式
TEL:010-82561037
Fax: 010-82561614
QQ: 100164630
Mail:gaojian@comprg.com.cn

  友情链接
 
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved
京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089