Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Typing in two text boxes

 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying keypress event but it is showing blank for all the characters alert is just "Character typed: ".


 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic