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
176 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:Mike Miller
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Mike Miller
ID: 40423831
Works like a charm. Thanks!
0
 

Author Comment

by:Mike Miller
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

756 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