Pre Fill list menu with multiple selections

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Pre Fill list menu with multiple selections

    Anybody tell me why this code is not working? I've tried it like every which
    way I can possibly think of but I can't get the values to show up as selected.
    Help!?

    <select name="partJobTitle" class="directoryselects" id="partJobTitle"
    multiple height"4">
    <cfoutput query="JobTitles">
    <option value="#JobTitles.jobtitleName#"
    <cfloop list="get_username.Title" delimiters="," index="i">
    <cfif JobTitles.jobtitleName IS "i">selected</cfif></cfloop>
    >#JobTitles.jobtitleName#</option>
    </cfoutput>
    </select>

    AkronNick Guest

  2. Similar Questions and Discussions

    1. Mail values from a List with Multiple Selections with PHP
      Hi, I have a little problem, I have a HTML-mailform with a List/Menu (named informatie) witch allows Multiple Selections (Hold CTRL-key and...
    2. Multiple Dynamic List Menu Help
      Hello. I'm a programming novice and I'm trying to create a two dynamically populated list and or jump menus. I'd like there to be a parent / child...
    3. multiple menu/list values inserted into one mysql column
      Simple problem here for the pros I'm sure. I have constructed a "rockshow" database in mysql for local music artists/bands and I made an input form...
    4. Filemaker mobile, list/menu and multiple entries...
      On the desktop shift click selects multiple, is there an equivalent palm action in FM Mobile to enter multiple items from a menu or list? This may...
    5. display list box selections and use for combo box
      I have a list box in which users will make one to several selections. When the user is finished making selections, I need to display them in a...
  3. #2

    Default Re: Pre Fill list menu with multiple selections

    <cfif JobTitles.jobtitleName IS 'i'> You're testing 'i' like it's a string...
    i doubt you're really checking to see if someone's job title is 'i'. You want
    to check for i as a variable.. not as a literal string. I'd do it like this:
    <cfif JobTitles.jobtitleName eq i> other ways of doing it would be: <cfif
    JobTitles.jobtitleName IS '#i#'> <cfif JobTitles.jobtitleName eq #i#> -Jon

    Jon Block Guest

  4. #3

    Default Re: Pre Fill list menu with multiple selections

    Right, I understand what you are saying about string literals, etc.. And I have
    tried all the possible ways of doing it and it does not work the other 2 ways
    you suggested either... I had already tried those ways but did try again after
    your post. Any other ideas by chance?

    AkronNick Guest

  5. #4

    Default Re: Pre Fill list menu with multiple selections

    jobtitles.jobtitlename obviously doesn't equal #i#. Just make a page that
    prints out each of the values. If they do match, look closely at the HTML
    output when you run the page...maybe theres a typo in your select elment. Jon

    Jon Block Guest

  6. #5

    Default Re: Pre Fill list menu with multiple selections

    I've ran that test, the values print fine.. still no luck comparing and getting
    them selected. The values I compare to come straight from a database table, I
    know for sure all the values would match up... Seriously frustrating here

    AkronNick Guest

  7. #6

    Default Re: Pre Fill list menu with multiple selections

    Is the question 'why won't the names populate?' or os it 'why won't it select
    the appropriate name?' You both seem to be going over the 'i' validation,
    which is merely a loop to select a certain name, not the portion that actually
    populates the names in the dropdown. If you are asking why it is not selecting
    a proper name in the list, I suspect it is because you told it the list is
    'get_username.Title' (literally). It is not looking at 'get_username.Title' as
    a variable, but rather an entry. It should be '#get_username.Title#' if you
    want it to use a pre-populated variable containing a comma-delimited list.
    There is no reason for the names themselves, not to actually populate.

    SafariTECH Guest

  8. #7

    Default Re: Pre Fill list menu with multiple selections

    Populating the list is not the issue. I populate the list with a db table
    column of values. Then, I check a comma delimited list to see if any of the
    values in the comma delimited list equal any of the values in the populated
    list, if they do they should be selected. It's an 'update' form... so I want
    to prefill all the form with the existing values of the record I am updating.

    AkronNick Guest

  9. #8

    Default Re: Pre Fill list menu with multiple selections

    Then, as I stated, make sure you use the pound signs on your list variable,
    otherwise it reads it literally as the actual list and not as a variable
    containing a list. variable = 'name1,name2,name3,name4' list = 'variable'
    means the list contains 'variable' list = '#variable#' means the list contains
    'name1,name2,name3,name4' Your list variable has no pound signs in your
    example

    SafariTECH Guest

  10. #9

    Default Re: Pre Fill list menu with multiple selections

    I thought I was crazy for a second.. Man.. Thank you for the help both of you.
    No pound signs around my list, DUH, it was taking the entire comma delimited
    list and comparing that. OK, working now thanks for the help.. below code is
    what works:

    <select name="partJobTitle" class="directoryselects" id="partJobTitle"
    multiple height"4">
    <cfoutput query="JobTitles">
    <option value="#jobtitleName#"
    <cfloop list="#get_username.Title#" delimiters="," index="i">
    <cfif #jobtitleName# IS #i#>selected</cfif></cfloop>
    >#jobtitleName#</option>
    </cfoutput>
    </select>

    AkronNick 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