How to: Populate listbox with fields from DB

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

  1. #1

    Default How to: Populate listbox with fields from DB

    I created a .cfm page using various queries to output a company phone list (1.
    lname alpha, 2. dept, 3. branch). I then have it create a .PDF using the
    <cfdocument> tag.

    Now I am trying to recreate this site but allow the user to manually choose
    the parameters in which to query, creating a custom .pdf.

    The problem I am having is that I do not know how to call the fieldnames
    themselves to be available for queries, and I would like them, once selected,
    to not be available in the next list box. I'm also not sure if the #index# used
    in the select is correct. Maybe it should be #recordindex# ?

    I have my select * query, and <form action = "phonebook.cfm" method = "post">
    <cfoutput query = "getfields">
    <select name = "param#index#">
    <option value = DON"T KNOW WHAT TO PUT HERE>
    </select>
    </cfoutput>
    </form>

    Maybe my logis isn't right as well.

    Captain Ru Guest

  2. Similar Questions and Discussions

    1. Populate form fields with Unicode data using FDF Toolkit
      Does anyone know about populating PDF Form dynamically with Unicode (read Arabic) data?! It displays English data correctly but displays jumbled data...
    2. Combining 2 Fields Using ListBox.DataTextField
      I have a ListBox control which I am using with databinding. However, the text that I want to be displayed is a combination of two fields (in this...
    3. listbox to populate a listbox
      I am trying to use a listbox that I have setup using flash remoting call to a db. What I want to happen is when you click on a item in first the...
    4. Populate form values based on previous same form fields
      This message is cross posted in alt.comp.lang.php & comp.lang.javascript I have a form for a user to input an establishment's hours and what time...
    5. How to populate the form fields from another drop down list
      Hello, I would like to populate form fields from one drop down list in the same page. The drop down list's value is from SQL database. When...
  3. #2

    Default Re: How to: Populate listbox with NAME of fields from DB

    the cfquery tag returns a property called columnlist which is the name of each column returned from the query. so you could do a select * and then loop over columnlist.

    dave.
    warddc Guest

  4. #3

    Default Re: How to: Populate listbox with NAME of fields from DB

    So I'm going to want columnlist and loop through to index. Is there a
    columncount, like the recordcount attribute?

    That way I could use that to determine how many 'option value's i will use. If
    possible have....

    Maybe I'll have one listbox, then have another popup if a record is selected
    for use in a query OR allow multiple selections via one listbox....

    I want this to be as user-friendly and error-prone free. Thanks for your help!

    Captain Ru Guest

  5. #4

    Default Re: How to: Populate listbox with NAME of fields from DB

    you don't need to know how many options tags to create. just loop over the
    list that was returned.

    <cfloop index="item" list="#myquery.columnlist#">
    <option><cfoutput>#item#</cfoutput>
    </cfloop>

    better yet just use a cfselect form object and let it build the options
    automatically.

    <cfselect name="myselect" query="myquery" display="columnlist"
    value="columnlist">

    d

    d.

    warddc Guest

  6. #5

    Default Re: How to: Populate listbox with NAME of fields from DB

    well what I mean is that I want the user to custom create a phonelist based on
    parameters to be shown.

    This will let the user select from the first listbox to display the Lname, the
    next box the FName, third box Phone...Ext...and so on. The number of available
    boxes to choose shouldn't exceed the number of columnlist elements.

    I could also achieve the same results allowing multiple selections from one
    listbox.

    However, the other way could allow the user to custom sort as well based on
    all those criteria.

    Captain Ru 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