Sorry. I fixed the code so that is only applies it to text boxes and won't change the other values. Just apply the events to your text boxes and give your <body> tag an id:
Code:
<html>
<head>
<title>Textbox Test</title>
<script type="text/javascript">
function applyTextboxValues(parentNodeId, txt) {
var inputs = document.getElementById(parentNodeId).getElementsByTagName("input");
for(var i = 0; i < inputs.length; ++i) {
if(inputs[i]["type"] == "text") inputs[i].value = txt;
}
}
</script>
</head>
<body id="bodyId">
Textbox Test<br>
<br>
<pre>You can place any number of textboxes in a parent node (used commonly w/ the <body> tag, <span> tag, and <form> tag) with the 'onkeydown' and 'onkeyup' events attached. The tag must have an id, but no matter the number of textboxes, it doesn't take much code. Insert your element's id (in this scenario, 'bodyId' which is the body's id) into the first parameter of applyTextboxValues. Make sure that your body's id doesn't conflict w/ other element's ids. It is also suggested that the textbox's parent node is the <body> tag.</pre>
<input type="text" onkeydown="applyTextboxValues('bodyId', this.value);" onkeyup="applyTextboxValues('bodyId', this.value);"><br>
<input type="text" onkeydown="applyTextboxValues('bodyId', this.value);" onkeyup="applyTextboxValues('bodyId', this.value);"><br>
<input type="text" onkeydown="applyTextboxValues('bodyId', this.value);" onkeyup="applyTextboxValues('bodyId', this.value);"><br>
<input type="text" onkeydown="applyTextboxValues('bodyId', this.value);" onkeyup="applyTextboxValues('bodyId', this.value);">
</body>
</html>
All you have to do is take the new code and apply it to your HTML page. In my next post, I will do it for you. Just wait.
-magicyte
Bookmarks