This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Typing in two text boxes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Typing in two text boxes" Watch "Typing in two text boxes" New topic
Author

Typing in two text boxes

Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1526
I want to copy contents of one text from one into another this has to happen in real time as if I am typing in two text boxes simultaneously, how can I achieve this using javascript?



Above code lags by one key press.


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1526
I am trying keypress event but it is showing blank for all the characters alert is just "Character typed: ".


Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1526
Got it.

<html>
<script>
function copyTextBoxes(evt) {
// evt = window.event;
var groupNameTxt = document.getElementById('groupName');
var fnameTxt = document.getElementById('fname');
groupNameTxt.value=fnameTxt.value + " Users";
}


</script>
<body>
<form name="addLDAPApplicationGroup" action="demo_form.asp">
<input type="text" id="groupName" name="groupName" disabled value="disabled">

<input type="text" id="fname" name="fname" onKeyUp="copyTextBoxes(this)" onmouseup="copyTextBoxes(this)" onmouseover="copyTextBoxes(this)">

<input type="button" value="Submit">
</form>
</body>
</html>

 
jQuery in Action, 2nd edition
 
subject: Typing in two text boxes
 
Similar Threads
JS code not working.
translate from English to Hindi
How to remove Textbox Element using DOM in HTML
Is onSubmit() mandatory to write when SimpleFormController is used?
How to get back in old window from a new window