Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic Dropdown Box

Guest
Nov 06, 2012 Nov 06, 2012

Hello, I’m very new to coldfusion and I’m trying to modify the existing form. Here is my requirement…

I have two dropdown boxes, based on the first drop down box, I like to fill the box two. 

Table Emp,

EmployeeNbr, EmployeeName

1,John

2,David

3,Vic

Table Dep,

EmployeeNbr, DepNbr,DepName

1, 1, Wine

1,2,HP

1,3,IBM

2,1,Phone

2,2,Mouse

3,1,Cable

I will be using the cfquery to populate the dropdown box1, If user select the employee nbr2 in drop down box1 I like to display depends records in dropdown box 2. Please guide to code this.

Thanks

728
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 06, 2012 Nov 06, 2012

You're never too new to learn good habits.  What you are attempting is called "related selects" and the most effective way to accomplish it in ColdFusion these days is with binding.  A google search on "cfinput bind" will lead you to explanations and code samples.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 06, 2012 Nov 06, 2012

Thanks, I will google it now.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 06, 2012 Nov 06, 2012

Hello Dan, I did google for "cfinput bind" not finding what I was looking for, do you have any example.

Thanks

---Srini

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 06, 2012 Nov 06, 2012

Here is something I actually did.  It's not quite what you want, but it should get you started.

<cfselect name="PatientSatisfactionClinicName" bind="cfc:PatientSatisfactionClinics.GetClinicNames()" bindonload="yes" value="name" display="name"></cfselect>

name
<cfinput name="newClinicNameByName" type="text" maxlength="50" bind="{PatientSatisfactionClinicName.text}" bindonload="yes">

And this is the function in the cfc.

<cffunction name="GetClinicNames" access="remote" returntype="query">

<cfset var clinicNames = QueryNew("a")>

<cfquery name="clinicNames" datasource="dw">

select distinct name from patient_satisfaction_clinic

</cfquery>

<cfreturn clinicNames>

</cffunction>

The cfc and cfm files have to be in the same directory

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 06, 2012 Nov 06, 2012
LATEST

Thanks, Let me try.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources