Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DYNAMICALLY GENERATING NAME BASED ON DROPDOWN 1

Status
Not open for further replies.

kingjjx

Programmer
Joined
Sep 18, 2001
Messages
181
Location
US
Hi, I have a dropdown list of employee ID's ... I want to be able to generate their name somewhere in the page once the employee choooses his/her ID.

EX. The name field is empty but once an Employee ID is chosen, the name for that ID will appear.

Emplyee ID [ dropdown ]

Name: ____________


All info is stored in a SQL database.

How do i do this ? thank you

 
Here is a way to do it -- set the id of the option to the name of the user, then use javascript to populate it:

e.g

<cfquery name=&quot;foo&quot; datasource=&quot;bar&quot;>
Select EmployeeID, EmployeeFirst, EmployeeLast from MyTable
</cfquery>
<form name=&quot;frm1&quot;>
<select name=&quot;test&quot; onchange=&quot;frm1.text1.value = frm1.test[frm1.test.selectedIndex].id;&quot;>
<cfoutput query=&quot;foo&quot;>
<option value=&quot;#EmployeeID#&quot; id=&quot;#EmployeeFirst# #EmployeeLast#&quot;> #EmployeeID#
</cfoutput>

</select>

<br><br>
<input type=&quot;Text&quot; name=&quot;text1&quot; value=&quot;&quot;>
</form>

If you are not familiar with javascript, take notice of name of the form and the name of the form fields to make sure you are referencing them properly.
 
CFDUDE, the code you posted worked and you dont understand how much help you just gave me.

Thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top