<script type="text/javascript" language="JavaScript">
<!-- Copyright 2001 William Bontrager
// You may use this JavaScript code so long as the copyright line, the more info link, and
// the instructions remain with the code. For additional form creation and script
// customizing information, see the article "JavaScript Quiz Program" linked from
// http://willmaster.com/possibilities/archives/
// On the next line, specify the number of answer choices at each question:
NumChoices = 4;
// Leave next five lines as is.
function CalculateScore()
{
var score = 0;
for (i = 0; i < NumChoices; i++)
{
.....
}
<morehtml>html</morehtml>
Wed, 09/26/2007 - 21:13
#1

Re: keep newlines in HTML
Re: keep newlines in HTML
<script type="text/javascript" language="JavaScript"> <!-- Copyright 2001 William Bontrager // You may use this JavaScript code so long as the copyright line, the more info link, and // the instructions remain with the code. For additional form creation and script // customizing information, see the article "JavaScript Quiz Program" linked from // http://willmaster.com/possibilities/archives/ // On the next line, specify the number of answer choices at each question: NumChoices = 4; // Leave next five lines as is. function CalculateScore() { var score = 0; for (i = 0; i < NumChoices; i++) { // Begin calculation block. // There should be one "if( ... value); }" line for each question. Each line needs to have the name // of the form element specified in two places, in front of the open square brackets "[" if(document.quizform.Q1[i].checked) { score += parseInt(document.quizform.Q1[i].value); } if(document.quizform.Q2[i].checked) { score += parseInt(document.quizform.Q2[i].value); } if(document.quizform.Q3[i].checked) { score += parseInt(document.quizform.Q3[i].value); } if(document.quizform.Q4[i].checked) { score += parseInt(document.quizform.Q4[i].value); } if(document.quizform.Q5[i].checked) { score += parseInt(document.quizform.Q5[i].value); } if(document.quizform.Q6[i].checked) { score += parseInt(document.quizform.Q6[i].value); } if(document.quizform.Q7[i].checked) { score += parseInt(document.quizform.Q7[i].value); } if(document.quizform.Q8[i].checked) { score += parseInt(document.quizform.Q8[i].value); } if(document.quizform.Q9[i].checked) { score += parseInt(document.quizform.Q9[i].value); } if(document.quizform.Q10[i].checked) { score += parseInt(document.quizform.Q10[i].value); } if(document.quizform.Q11[i].checked) { score += parseInt(document.quizform.Q11[i].value); } if(document.quizform.Q12[i].checked) { score += parseInt(document.quizform.Q12[i].value); } if(document.quizform.Q13[i].checked) { score += parseInt(document.quizform.Q13[i].value); } if(document.quizform.Q14[i].checked) { score += parseInt(document.quizform.Q14[i].value); } if(document.quizform.Q15[i].checked) { score += parseInt(document.quizform.Q15[i].value); } if(document.quizform.Q16[i].checked) { score += parseInt(document.quizform.Q16[i].value); } if(document.quizform.Q17[i].checked) { score += parseInt(document.quizform.Q17[i].value); } if(document.quizform.Q18[i].checked) { score += parseInt(document.quizform.Q18[i].value); } // End calculation block. // Leave the rest of the JavaScript code as is. } document.quizform.totalscore.value = score; } // --> </script> <span>test</span>Re: keep newlines in HTML
With tomorrows nightly you won't even have to check the source as it will be shown in white-space:pre (to check online use the php samples)
Re: keep newlines in HTML