Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks, I will google it now.
Copy link to clipboard
Copied
Hello Dan, I did google for "cfinput bind" not finding what I was looking for, do you have any example.
Thanks
---Srini
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks, Let me try.