Jack Hillard
Jack Hillard

Reputation: 596

Why can't I update this table with the same code used in another place using Javascript?

The table cell updates correctly to "" (empty) in the changeScore function, but that same cell does not change at all in the editUpdate function when I try to place the new score in there. It just stays empty. Any ideas?

function changeScore(playerKey)
{
    var table = document.getElementById("scoreTable");

    players[playerKey].score = players[playerKey].oldScore;
    table.rows[currentRound - 1].cells[playerKey + 1].innerHTM = '';

    document.getElementById('inputArea').innerHTML = '<font size="6">Did <b>' + players[playerKey].name + '</b> take <b>' + players[playerKey].bid + '</b> trick(s)?</font><br /><button value="Yes" id="yesButton" onclick="editUpdate(' + playerKey + ', \'yes\')">Yes</button>&nbsp&nbsp&nbsp&nbsp<button value="No" id="noButton" onclick="editUpdate(' + playerKey + ', \'no\')">No</button>';
}

function editUpdate(thePlayerKey, answer)
{
    var table = document.getElementById("scoreTable");

    players[thePlayerKey].oldScore = players[thePlayerKey].score;

    if (answer == "yes"){
        **
    }else{
        **
    }

    table.rows[currentRound - 1].cells[thePlayerKey + 1].innerHTM = '<font color="' + players[thePlayerKey].font + '">' + players[thePlayerKey].score + '</font>';

    document.getElementById('inputArea').innerHTML = '<button onclick="startRound()">Start Round</button>&nbsp&nbsp&nbsp&nbsp&nbsp<button onclick="edit()">Edit Scores</button>';

}

Upvotes: 0

Views: 27

Answers (1)

Winestone
Winestone

Reputation: 1500

innerHTM should be innerHTML

This:

table.rows[currentRound - 1].cells[playerKey + 1].innerHTM = '';

Should be:

table.rows[currentRound - 1].cells[playerKey + 1].innerHTML = '';

(Same for 2nd function)

Upvotes: 1

Related Questions