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
173 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
ID: 40423296
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
ID: 40423831
Works like a charm. Thanks!
0
 

Author Comment

by:mwmiller78
ID: 40425584
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
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…

777 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