Need to put value from drop down into a text box using JavaScript

I have an ASP.Net web form and I need to add a drop down selector, "ActivityList", that when an item is selected will put the value, e.g. "120" into a text box, "ActivityCode".

It would also be nice, but not necessary, to maintain the list of text and values in an array in the JavaScript.

I'm already using some JavaScript in an external .js file and some jQuery.  They don't seem to always play nice together, so I need to watch for that.

Thanks!
(P.S. I don't really know how to write JavaScript, but I can make minor changes to customize something for my purposes.)
<tr class="NewQuestion">
	<td align="right">
		Activity:
	</td>
	<td>
		<select name="ActivityList" id="ActivityList" size="1">
			<option value="120">Job Search Job Readiness</option>
			<option value="210">Community Service</option>
			<option value="220">Work Experience</option>
			<option value="731">Vocational Training</option>
			<option value="310">Job Skills Training Directly Related</option>
		</select>	
	</td>
	<td>
		<input type="text" name="ActivityCode" id="ActivityCode" />
	</td>
</tr>

Open in new window

LVL 1
megninAsked:
Who is Participating?

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

x
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.

leakim971PluritechnicianCommented:
Try this :


<select name="ActivityList" id="ActivityList" size="1" onchange="$('#ActivityCode').val(this.value)">

Open in new window

0

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
leakim971PluritechnicianCommented:
(it replace line 6)
0
HainKurtSr. System AnalystCommented:
no jQuery option:

<select name="ActivityList" id="ActivityList" size="1" onChange="document.getElementById('ActivityCode').value=this.value">
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

megninAuthor Commented:
leakim971, oh, that's just too simple.  ;-) And it worked great.

In my reading of "best practices" some post, somewhere, said that scripts should always go into external files, so I was expecting something more complicated.  This looks like a case where "Best Practices" may be overkill, when "simple" works just fine.

I saw another comment come in just now, so I'll go read that one.  I would still like to get a script that uses an array for the list so I can use it in future projects as well. ;-)
0
megninAuthor Commented:
HainKurt, thank you for the no jQuery option!

What does the size="1" attribute in my <select /> object do?
0
leakim971PluritechnicianCommented:
0
megninAuthor Commented:
Oh!, cool.

I love those w3shools.com "Try it yourself" examples!!!

Thank you both for the nice simple script!!!  I'm learning, so the complicated code can be frustrating. ;-)
0
leakim971PluritechnicianCommented:
You're welcome! Thanks for the points!
0
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
JavaScript

From novice to tech pro — start learning today.