Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My website page doesn't work but JS Fiddle code does - JavaScript and HTML quiz

That's the code:

function pagechange(frompage, topage) {
    var page = document.getElementById('formpage_' + frompage);
    if (!page) return false;
    page.style.visibility = 'hidden';
    page.style.display = 'none';

    page = document.getElementById('formpage_' + topage);
    if (!page) return false;
    page.style.display = 'block';
    page.style.visibility = 'visible';

    return true;
}

var currentShown = "";

function unhide(rad) {
    var id = "answer" + rad.id.replace("-", "");
    var answer = document.getElementById(id);
    if (answer) {
        var current = document.getElementById(currentShown);
        if (current) current.className = "hidden";
        currentShown = id;
        answer.className = "unhidden";
    }
}

var score = 0;

function scoreIncrement() {
    score++;
    document.getElementById("score").innerHTML = score;
}

http://jsfiddle.net/NSzxN/

Then here's my website page with that code:

http://elearning.easy2dev.com/quiz_template_3.php

When John is clicked it should increment the score by 1 and then show answer boxes underneath, nothing happens but in JS Fiddle it works. It used to work but I seem to have broken it somehow.

like image 857
John Vasiliou Avatar asked Feb 28 '26 13:02

John Vasiliou


1 Answers

If you would use FireFox with the FireBug extension, you would see this error:

illegal character in quiz_t...e_3.php at line 61:
}​
-^

Which refers to the following code:

function scoreIncrement() {
    score++;
    document.getElementById("score").innerHTML = score;
}​ // <<-- mysterious zero-length character here
</script>
like image 119
Kaii Avatar answered Mar 03 '26 02:03

Kaii



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!