This should be pretty straightforward, but I don’t see it…
I have an existing quiz in js that nicely writes a results page, from values stored in a cookie. I want to provide a way to email the quiz results (from the cookie) to an addressee from either a free-text email or a dropdown list of email addresses.
How can I modify this for the follow-on desire to email the results:
[code=php]// Function to print quiz question results
// out – Document output reference
// prob – Number of problem
// total – Total # of possible correct answers
// returns – Number of correct answers for this problem
function printQuizInfo(out, prob, total) {
var ques, correctAns, wrongAns, percent;
var cookie = “q” + prob;
out.write(“<TR>n <TD align=”left”>” + prob + “n” +
” <TD align=”center”>”);
correctAns = parseInt(getSubValue(“ans”, cookie));
out.write(correctAns + “n <TD align=”center”>”);
wrongAns = total – correctAns;
out.write(wrongAns + “n <TD align=”right”>”);
percent = Math.round((correctAns / total) * 100);
printPercent(out, percent);
return correctAns;
}
// Function to print quiz totals
// out – Document output reference
// total – Total # of questions in quiz
// right – # of questions answered right
function printQuizTotal(out, total, right) {
var percent;
out.write(“<TR>n <TH align=”left”>Totaln <TD align=”center”>”);
out.writeln(right);
out.write(” <TD align=”center”>”);
out.writeln(total-right);
out.write(” <TD align=”right”>”);
percent = Math.round((right / total) * 100);
printPercent(out, percent);
}
I think it should be easy enough to take these lines:
[code=php]out.write(“<TR>n <TD align=”left”>” + prob + “n” +
” <TD align=”center”>”);
correctAns = parseInt(getSubValue(“ans”, cookie));
out.write(correctAns + “n <TD align=”center”>”);
wrongAns = total – correctAns;
out.write(wrongAns + “n <TD align=”right”>”);
percent = Math.round((correctAns / total) * 100);
printPercent(out, percent);
return correctAns;
and modify the table wrappers to turn the results into inputs on a form to submit to the email I want to send. But I don’t see quite how to include the input tags for correct rendering.
Like I said, this should be easy, but I’m totally not seeing it today.
Suggestions for starting points or some rough code snips very welcome.
-Spaz68
?