Whenever I click on a certain letter, I want the first slot value from the beginning to be changed to the letter value I clicked on. Is it correct that I put the letter.onclick = letterClick(this); into the for loop or should I realise it some other way. Also, what should the letterClick() function contain?
// Makes slots and letters for the chosen word.
function maker() {
for (i=0; i<word.length; i++) {
var slot = document.createElement("input");
var letter = document.createElement("input");
var letters=(shuffledWord).split("");
slot.type = "submit";
slot.value = "";
slot.id = "slot" + i;
slot.setAttribute('id', 'slot');
letter.type = "submit";
letter.value = letters[i];
letter.id = "letter" + i;
letter.onclick = letterClick(this);
letter.setAttribute('id', 'letter');
document.getElementById("slotbar").appendChild(slot);
document.getElementById("letterbar").appendChild(letter);
}
}