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

Composant cfc ou include

New Here ,
Sep 11, 2018 Sep 11, 2018

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

2.3K
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

correct answers 1 Correct answer

Community Expert , Oct 06, 2018 Oct 06, 2018

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"/>

Translate
Community Expert ,
Oct 02, 2018 Oct 02, 2018

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

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
Community Expert ,
Oct 03, 2018 Oct 03, 2018

If you wish to get distinct countries, then modify the query to

SELECT DISTINCT pays

FROM Monde

ORDER BY pays

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
Community Expert ,
Oct 06, 2018 Oct 06, 2018
LATEST

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"/>

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