- Mar 26, 2005
- 4,094
- 123
- 106
If you just copy paste the code and save as html document, you'll see that this displays buttons from A to Z and buttons for backspace and clear, which can be typed into the input box.
I want to separate the buttons such that I only have 9 per line. I have no idea how to do that, and I could really use some help.. Thanks!
PS: Off course, the last line will not have 9 buttons, and that is fine. It will have whatever is left.
I want to separate the buttons such that I only have 9 per line. I have no idea how to do that, and I could really use some help.. Thanks!
PS: Off course, the last line will not have 9 buttons, and that is fine. It will have whatever is left.
Code:
<!DOCTYPE html>
<html>
<head>
<title>Typewriter</title>
<script>
function backSpace() {
var t = document.typing.disp.value;
var n = t.substr(0, t.length - 1);
document.typing.disp.value = n;
}
</script>
</head>
<body>
<form id="typing" name="typing">
<input type="text" id="disp" name="disp" size="50" value="" disabled="disabled" />
<script type="text/javascript">
for (k = 65; k <= 90; k++) {
letter = String.fromCharCode(k);
document.write("<input type=\"button\" value=\""+letter+"\" onclick=\"document.typing.disp.value += '"+letter+"';\" />");
}
</script>
<input type="button" value="CLR" onclick="document.typing.disp.value = '';" />
<input type="button" value="<--" onclick="backSpace();" />
</form>
</body>
</html>