Populating SELECTED of CFSELECT with different query

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Populating SELECTED of CFSELECT with different query

    I am trying to populate a CFSELECT from a query (which is working fine), but I
    want the SELECTED value to come from a
    different query. The values are identical because the second table is
    populated with values from the first table on a seperate page. Is there anyway
    to do this? Basically this is what I want to do

    <cfquery name="query1">
    SELECT * FROM Table1
    </cfquery>

    <cfquery name="query2">
    SELECT * FROM Table1
    WHERE Name = '#query1.Name#'
    </cfquery>

    <cfselect query="table1" display="Name" value="Name" selected="#query2.Name#">

    I know that you cannot use multiple queries, but I know there must be a way to
    do this, but I can't think of how.

    ThomasWood Guest

  2. Similar Questions and Discussions

    1. how do you populate cfselect when cfgrid selected row ischanged
      hi can anyone enlighten me as to how to pass data to a cfselect from a cfgrid i am using a listner function so that the grid can populate form...
    2. Specifically Referencing and Populating a CFSELECT Datafield
      QUESTION ..... How do I get the CFSELECT (CRITS) to populate the data component as well as the labelField component. There must be a path ...
    3. selected= not working in cfselect
      I am working on my admin interface for a department and I need to have a cfselect actually hilight the value that is passed from a query (like it is...
    4. CFSELECT problem with Selected attribute
      Hello, I've found that if I have a simple CFSELECT statement using a query like the following: <CFSELECT Name="Field1" Size=1 Query="Names"...
    5. item selected cfselect with cfgrid
      If anyone's found a better way to make an item selected in a cfselect using cfgrid that the following, let me know: <cfgrid name="AddressGrid"...
  3. #2

    Default Re: Populating SELECTED of CFSELECT with different query

    Took care of it like this

    <cfselect name="selectname">
    <cfloop query="query1">
    <cfif query1.tablename EQ query2.tablename>
    <option Value="<cfoutput>#query2.name#</cfoutput>"
    selected><cfoutput>#Name#</cfoutput></option>
    <cfelse>
    <option
    Value="<cfoutput>#query2.name#</cfoutput>"><cfoutput>#Name#</cfoutput></option>
    </cfif>
    </cfloop>
    </cfselect>

    ThomasWood Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139