I have a code like this:
<html>
<head>
<script language="javascript">
window.onload = function() {
for(i = 0; i < 26; i++) {
var x = document.createElement("INPUT");
x.setAttribute("type", "button");
x.setAttribute("value", String.fromCharCode(i + 65));
x.setAttribute("id", String.fromCharCode(i + 65));
x.setAttribute("onclick", "isTOF(self.id)");
document.body.appendChild(x);
}
}
function isTOF(v) {
alert(v);
}
</script>
</head>
<body>
</body>
</html>
I wanted to make it alert its own alphabet(value), but it doesn't work.
So for example, when I click A Button, the program should alert 'A'.
But it alerts 'undefined'.
I don't know what the problem is.
I want to make my code work properly.
How can I make it?
self.idis?selfdoesn't existselfdoesn't exist?this.idwill work ...