sorry..
是保存所有答案到一个文本文件中。

解决方案 »

  1.   

    <html>
    <head>
    <script language=javascript>
    var fso, tf; 
    var i = 1;
    var question = new Array();
    var answer = new Array();
    question[0] = "Who is David Beckham's wife?";
    question[1] = "What is M Jordan's height?";
    question[2] = "How old are you?";function ques()
    {
        if(document.all.ans.value == ""){
        alert("Please Answer.");
    document.all.ans.focus();
        return false;
    }
        if(i<3){
        document.all.tb.rows[0].cells[0].innerText = question[i];
    answer[i-1] = document.all.ans.value;
    document.all.ans.value = "";
    document.all.ans.focus();
    i++;
    }
    if(i == 4){
    answer[2] = document.all.ans.value;
    io();
    }
    if(i == 3){
        document.all.ques.value = "Save";
    i++;
    }
    }function init()
    {
        document.all.tb.rows[0].cells[0].innerText = question[0];
    document.all.ans.focus();
    document.all.ans.value = "";
    }function io(){
    fso = new ActiveXObject("Scripting.FileSystemObject"); 
    // creat new file 
    tf = fso.CreateTextFile("c:\\testfile.txt", true); 
    // write 
    tf.WriteLine(question[0] + " : " + answer[0]) ; 
    tf.WriteLine(question[1] + " : " + answer[1]) ; 
    tf.WriteLine(question[2] + " : " + answer[2]) ; 
    // close 
    tf.Close();
    } </script>
    </head>
    <body onLoad="init();">
    <center>
    <table width="351" border="0" cellspacing="0" cellpadding="0" id="tb">
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><input name="ans" type="text" size="50" maxlength="50"></td>
      </tr>
      <tr>
        <td>
              <input type="button" name="ques" value="Question" onClick="ques();">
        </td>
        </tr>
    </table></center>
    </body>
    </html>还是没弄清提交和保存有什么分别,最后的save按钮可以把结果保存到一个文本文件中了,楼主看看还有什么问题
      

  2.   

    是这样的:保存就是把答案保存在一个文本文件中(页面中有方法返回所有答案的字符串,中间有分隔字符分隔),不过要实现页面无刷新,所以要采用WebService.htc。现在要在WebService中写个保存方法,把所有答案保存在一个文本文件中,后台取最后一次保存的所有答案并写到数据库中去。提交和保存差不多,好像多了像用户ID,考试试卷ID之类的,我也是刚刚接触这个任务,所以自己也没怎么弄明白,问起来也有点牛头不对马嘴的。再说声“Sorry”和“Thanks”现在我不会在WebService中调用页面中的方法。也不会在后台逻辑层调用,所以现在比较郁闷。
      

  3.   

    呵呵,WebService.htc我也没用过,剩下的帮不了你了  :)