Copy link to clipboard
Copied
Bonjour,
Je cherche à faire un composant ou un include pour faire une table qui alimente une autre table ( Pays - ville).
Etant débutant, j'ai trouvé du code sur un site mais malheureusement ...
<cfcomponent>
<cfform name="mycfform">
<CFQUERY datasource="#session.dbname#" name="AddTable">
SELECT
Pays,
Ville
FROM Monde
WHERE sitename='#session.site#'
<cfselect name="#Pays#" bind="cfc:bindFcns.getpays()" bindonload="true">
<option name="0">--#Pays#--</option>
</cfselect>
<cfselect name="#Ville#" bind="cfc:bindFcns.getvilles({#pays#})">
<option name="0">--#ville#--</option>
</cfselect>
</CFQUERY>
</cfform>
</cfcomponent>
Merci par avance
Marc
Oh, two more things, just in case you need them:
1) to display multiple items in the select list, use the size attribute.
2) remove the <br> tag to display the lists side by side.
For example, the following will display a maximum of 5 countries and 8 cities:
<cfselect name="pays" bind="cfc:Cfc.bindFcns.getPays()" bindonload="true" size="5"/>
<cfselect name="ville" bind="cfc:Cfc.bindFcns.getVilles({pays})" size="8"/>
Copy link to clipboard
Copied
I have looked at the files you sent me. We have to make some corrections:
1) In the above code for bindFcns.cfc, the 2-D array should be called paysArray not anneeArray (my bad).
2) Your database has no column called sitename, so your pays query should be
SELECT Pays
FROM Monde
ORDER BY pays
Copy link to clipboard
Copied
If you wish to get distinct countries, then modify the query to
SELECT DISTINCT pays
FROM Monde
ORDER BY pays
Copy link to clipboard
Copied
Oh, two more things, just in case you need them:
1) to display multiple items in the select list, use the size attribute.
2) remove the <br> tag to display the lists side by side.
For example, the following will display a maximum of 5 countries and 8 cities:
<cfselect name="pays" bind="cfc:Cfc.bindFcns.getPays()" bindonload="true" size="5"/>
<cfselect name="ville" bind="cfc:Cfc.bindFcns.getVilles({pays})" size="8"/>