Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom object 'game' doesn't have specified method
    primarykey
    data
    text
    <p>I'm trying to call a method <code>cardSelection()</code> from a <code>function game()</code> but instead I'm getting an error report which throws back to me the whole function with a "has no method cardSelection()" The idea is to access the method through the click of a button, which HTML tag is as follows:</p> <pre><code>&lt;img id="PlayerCard0" class="card" src="images/Cards/Mario.png" alt="Mario" title="Mario" onclick="game.cardSelection('PlayerCard0')"&gt; </code></pre> <p>I'm not posting the whole Javascript as I believe this to be the case of a mere declaration error, anyhow, <code>game()</code> and <code>cardSelection()</code> were declared as follows:</p> <pre><code>function game() { ... this.cardSelection = function(card) { var cardElem = document.getElementById(card); var id = cardElem.getAttribute("id"); var call = document.getElementById("call"); var select = function(card) { var found = 0; for (var card = 0, totalCards = 5; card &lt; totalCards; card++) { if (document.getElementById("PlayerCard" + card + "selected")) {found++} } if (found == 0) { call.setAttribute("onclick", "changeHand()"); call.childNodes[0].nodeValue = "Change"; } if (found &lt; 3) { id += "selected" setAttributes(cardElem, { "id" : id, "style": "position: relative; top: 1em;", "onclick" : "cardSelection('" + id + "')" }); } else { return; } } var unselect = function (card) { cardElem.removeAttribute("style"); id = id.replace("selected",""); setAttributes(cardElem, { "id" : id, "onclick" : "cardSelection('" + id + "')" }); var cardNumber = 0; var found = false; while (cardNumber &lt; 5 &amp;&amp; !found) { if (document.getElementById("playerCard" + cardNumber + "selected")) {found = true;} cardNumber++; } if (!found) { call.setAttribute("onclick", "compareHands()"); call.childNodes[0].nodeValue = "Hold"; } } if (id.indexOf("selected") &gt;= 0){unselect(card);} else {select(card);} } ... } </code></pre> <p>How <code>game()</code> is called:</p> <pre><code>window.onload = function openingScreen() { var startGame = document.createElement("a"); startGame.setAttribute("onclick", "game()"); startGame.appendChild(document.createTextNode("Play")); window.table = document.getElementById("table"); table.appendChild(startGame); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload