text to other text field
Posted: Mon Nov 14, 2005 2:08 pm
Original question:
what i want is what a user puts in text field A to go to text field B as soon as the user clicks away or if it was instant that would be cool too. what would be the JS for this?
Responce I got:
Well you can make it so that after so many characters it goes in there like so: (Lets say 8 chars for this example)
Or you can make it hop across when the user clicks away (although that sounds silly since they'd most likely either be "tabbing" to the other box or using the mouse but anyway:
my new reply now
i don't want the cursor to go to the new text field, what i want is the text that was entered into the first text box to be coppied to the 2nd one onblur probably or if it could be done in real time that would be great. the 1st part is at the top of the page then i just want as they scroll down the text will have been copied into the textbox at the bottom.
what i want is what a user puts in text field A to go to text field B as soon as the user clicks away or if it was instant that would be cool too. what would be the JS for this?
Responce I got:
Well you can make it so that after so many characters it goes in there like so: (Lets say 8 chars for this example)
Code: Select all
<script type="text/javascript">
<!--
function switchFocus(num, fromNode, toEl)
{
if (fromEl.value.length >= num) document.getElementById(toEl).focus();
}
// -->
</script>
A: <input type="text" id="A" name="A" onkeypress="switchFocus(8, this, 'B');" /> <input type="text" id="B" name="B" />Code: Select all
<script type="text/javascript">
<!--
function switchFocus(toEl)
{
document.getElementById(toEl).focus();
}
// -->
</script>
A: <input type="text" id="A" name="A" onblur="switchFocus('B');" /> <input type="text" id="B" name="B" />i don't want the cursor to go to the new text field, what i want is the text that was entered into the first text box to be coppied to the 2nd one onblur probably or if it could be done in real time that would be great. the 1st part is at the top of the page then i just want as they scroll down the text will have been copied into the textbox at the bottom.