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

Dynamic drop list

Explorer ,
Aug 26, 2012 Aug 26, 2012

Reference table

<Cfquery name ="getcode" datasource="this.datasource">
select *
from code
where (active_status = 'T')
</cfquery>


<CFSET FrequencyList="">
<CFSET FrequencyArray = Array(2)>
<CFSET FrequencyCount = "#GetCode.RecordCount#">
<CFOUTPUT Query="GetCode">
  <CFSET RecordNum="#GetCode.CurrentRow#">
  <CFSET FrequencyArray[#RecordNum#][1] = #GetCode.Frequencyt#>
  <CFSET FrequencyArray[#RecordNum#][2] = #GetCode.Frequency_desc#>
</Cfoutput>

<TD> Frequency</TD>
     <TR>
      <TD>
        <Select Name="Frequency">
        <CFLOOP From="1" to="#FrequencyCount#" INDEX="Conter">
     <CFIF #FrequencyArray[Counter][1]# eq 0>
                <Option Value="<CFOUTPUT>#FrequencyArray[Counter][1]#</Cfoutput>">
  <Cfoutput>#FrequencyArray[Counter][2]#</Cfoutput>
            <Cfelse>
  <Option Value="<CFOUTPUT>#FrequencyArray[Counter][1]# </Cfoutput>">
          <Cfoutput>#FrequencyArray[Counter][1]# (#FrequencyArray[Counter][2]#)</Cfoutput>
            </OPtion>
            </CFIF>
</CFLOOP> 
        </Select>
      </TD>
      </TR>
 

The above code will load the Frequency drop down list from a database reference table query.
I am looking for a way to have the Frequency drop down list populated but also have the
Frequency drop down list show the value selected from another table query.

For example:

If the database query of a refernce table shows:
450
520
730
890

The select drop down would show:
450
520
730
890

But now, if a database query of the record table shows that 730 was the value selected before, the screen should show

450
520
730
890

but the value 730 would be shown in the drop down list as selected.

Thanks,

Mike

399
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 ,
Aug 26, 2012 Aug 26, 2012
LATEST

The selected attribute of the cfselect tag does that quite nicely.

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