How can I use a drop-down list selection to populate a VB form textbox field automatically with editable text?

I need help writing javascript code that performs an automatic copy of text into a ASP.NET VB form textbox field based on the selection from a dropdown list selection. Here is an example below and I have attached a zip file with the code and document with screen capture of the form.

Dropdown List (Code1A): Yes, No

Description Field (Code1B): (multiple line of Text)

"Some static text copied from hidden field or embedded within the code ........................."

I would great appreciate any assistance you can provide to help me to get this working. Thank you in advance!
Jaime BonillaIT SpecialistAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Here is a sample on how to do it
      <select data-target="textfield">
        <option value=""> -- SELECT ONE -- </option>
        <option value="Yes" data-text="Text to copy for option 1">Yes</option>
        <option value="Yes - Control state" data-text="Text to copy for option 2">Yes - Control state</option>
        <option value="No" data-text="Text to copy for option 3">No</option>
        <option value="No - Control state" data-text="Text to copy for option 4">No - Control state</option>
      <input type="text" id="textfield"/>

Open in new window

$(function() {
  $('select').change(function() {
    var txt = $(this).data('target');
    var text = $('option:selected', $(this)).data('text');
    $('#' + txt).val(text);

Open in new window

Working sample here
How the code works
1. The <select> has a custom data attribute that tells us what text box to populate with the text
2. Each <option> element has a custom data attribute (data-text) that tells us what to put in the box when that option is selected
3. We have a .change event handler on the <select> that when fired
    a. Gets the target from this (the changed <select>).
    b. Finds the selected <option> and gets the text to show from its data-text attribute

The code is generic so that you can add as many select / text pairs as you wish.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jaime BonillaIT SpecialistAuthor Commented:
Thank you for the solution, it is exactly what I was looking for.  The sample page you created is a great way to see the code at work. That was really cool!
Julian HansenCommented:
Thank you and you are most welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.