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
181 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
Suggested Courses
Course of the Month10 days, 13 hours left to enroll

632 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