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

How get unique option fileds in a dynamic dropdown box

New Here ,
Apr 22, 2014 Apr 22, 2014

Copy link to clipboard

Copied

I'm trying to get single select options in a dropdown menu.

The data is coming from two database.

My CFQuery looks like


<cfquery name="related" datasource="ISSUE">
SELECT sparprod
FROM Related
where Active = 'Yes'
union all
select sparprod from TBL_issue
WHERE issue_number = <cfqueryparam value="#URL.issue_number#" cfsqltype="cf_sql_numeric">
ORDER BY sparprod ASC
</cfquery>

  <td>

        <select name="sparprod" id="sparprod" >

          <cfoutput query="related">

            <option value="#related.sparprod#" <cfif (isDefined("rs_issue.sparprod") AND related.sparprod EQ rs_issue.sparprod)>selected="selected"</cfif>>#related.sparprod#</option>

          </cfoutput>

        </select>

And the output in the dropdown box looks like

PRODUCTS

SPARES

SPARES

HOW can i have only ONE TIME Spares.

I've got this problem with all my dynamic dropdown boxes.

Thanks

For your help in advance

Klaas

TOPICS
Advanced techniques

Views

270

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
Guide ,
Apr 22, 2014 Apr 22, 2014

Copy link to clipboard

Copied

LATEST

Assuming "SPARES" doesn't appear twice in the Related table, UNION ALL may be adding a redundant "SPARES" record from the TBL_issue table.  Try using UNION instead.  If there are duplicates within either or both tables, try using SELECT DISTINCT in one or both places.

-Carl V.

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