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

Composant cfc ou include

New Here ,
Sep 11, 2018 Sep 11, 2018

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

Views

1.1K

Translate

Translate

Report

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

Votes

Translate

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

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

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Documentation