JavaScript


JavaScript

Aukkotehtäviä JavaScriptillä (ecmascriptilla).

//<![CDATA[
<!--
var score=0;
 
/* terord Copyright Tero Karvinen http://www.iki.fi/karvinen */
 
function cleanans(ans)
{
        ans = ans.toLowerCase();
        ans = ans.replace(/./g,'');
        return ans;
}
 
function s(input) // score (evaluate) one answer
{
        if (input.value!="") {
                if ( cleanans(input.name) == cleanans(input.value) ) {
                        score++;
                        input.className="right";
                        input.value = input.name;
                        input.disabled = "disabled";
                } else {
                        input.className="wrong";
                        //input.disabled = "disabled"; // to allow fixing errors indefinetly comment this out 
                                                     // and change class "wrong" background to white
                }
                document.terordcontrol.score.value=" "+score+" / "+document.f.elements.length;
        }
}
 
function revealall()    // reveal all answers
{
        for (var i=0; i<document.f.elements.length; i++) {
                        input = document.f.elements[i];
                        input.disabled = "disabled";
                        if ( cleanans(input.name) != cleanans(input.value) ) {
                                input.value = input.name;
                                input.className="corrected";
                        }
        }
}
 
//-->
//]]>

ps. Pois paha pakkoruotsi.


Posted in Old Site | Comments Off on JavaScript

Comments are closed.