Solved

Populating a textbox with text in another textbox as a user types AJAX or JS ASP.NET(VB)

Posted on 2014-11-04
3
169 Views
Last Modified: 2014-11-05
I have 3 textboxes names tbEntry1, tbEntry2, and tbResult

I'm looking for a way, hopefully with an AJAX control or possibly javascript, that I can populate tbResult with the results of tbEntry1 and tbEntry2 on the fly in a format something like:

tbEntry1.text & "-" & tbEntry2.text

Is there an AJAX method to do this? Javascript? Better idea?
0
Comment
Question by:mwmiller78
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Brian Tao earned 500 total points
Comment Utility
Use javascript since everything is on screen, so that you can avoid unnecessary traffic between the server and your browser.  This should work:
<html>
<head>
<script>
function populate_it(){
  var d = document;
  d.getElementById("tbResult").value = d.getElementById("tbEntry1").value+"-"+d.getElementById("tbEntry2").value;
}
</script>
</head>
<body>
tbEntry1: <input type="text" name="tbEntry1" id="tbEntry1" oninput="populate_it()"><br/>
tbEntry2: <input type="text" name="tbEntry2" id="tbEntry2" oninput="populate_it()"><br/>
tbResult: <input type="text" name="tbResult" id="tbResult">
</body>
</html>

Open in new window

0
 

Author Comment

by:mwmiller78
Comment Utility
Works like a charm. Thanks!
0
 

Author Comment

by:mwmiller78
Comment Utility
I've moved the textboxes into a repeater nested in a GridView. Questions on how to change the JS here:

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_28551834.html
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now