Professional Web Applications Themes

LEN of SELECT variable always the same? - Coldfusion - Advanced Techniques

I have a mulitple select variable that always seems to come up with the same length of 8, when I try to use a LEN by using Evaluate it always comes up as 4, the number does not change with the number of groups found in the getshares query. This is being used in an edit page for existing data in a select list, there is follow on error control that depends on the length of the string (shr_list). The code is as follows, how can I get the actual length of the string for this data field (shr_list)? <cfquery ...

  1. #1

    Default LEN of SELECT variable always the same?

    I have a mulitple select variable that always seems to come up with the same
    length of 8, when I try to use a LEN by using Evaluate it always comes up as 4,
    the number does not change with the number of groups found in the getshares
    query. This is being used in an edit page for existing data in a select list,
    there is follow on error control that depends on the length of the string
    (shr_list). The code is as follows, how can I get the actual length of the
    string for this data field (shr_list)?

    <cfquery name="getshares" datasource="#dsname#">
    select id
    from groups
    </cfquery>

    <cfset shared_list=listtoarray(getmain.shr_list)>
    <cfset lst_cnt=listlen(getmain.shr_list)>

    <cfloop index="share" from="1" to=#lst_cnt#>
    <cfoutput>#shared_list[share]#</cfoutput><br>
    </cfloop>

    <SELECT NAME="shr_list" SIZE=3 MULTIPLE>
    <cfloop index="share" from="1" to=#lst_cnt#>
    <OPTION selected><cfoutput>#shared_list[share]#</cfoutput>
    </cfloop>
    <cfloop index="lst" from="1" to="#getshares.recordcount#">
    <OPTION><cfoutput>#getshares.group[lst]#</cfoutput>
    </cfloop>
    </SELECT>

    <cfoutput>#len("shr_list")#</cfoutput>

    <cfset gogo="evaluate(shr_list)">
    <cfoutput>#len("gogo")#<br></cfoutput>

    Any help would be greatly appreciated!



    Suva1 Guest

  2. #2

    Default Re: LEN of SELECT variable always the same?

    The length of the string "shr_list" is always 8 characters in length.
    The length of the string "gogo" is always 4 characters in length.
    Do you sense a common theme here?

    Please remove the quotes "" from around the variables.

    Is what you are asking for "How many selected items are there within the
    shr_list form element?"

    You cannot do it that way.

    On the Action page you could use the ListLen function, as a select box with
    multiple items selected returns are comma delimited list of selected values.





    Scott*e Guest

  3. #3

    Default Re: LEN of SELECT variable always the same?

    I removed the quotes and now the evaluated length is 18. I want to evaluate
    the length of the string, not the number of elements. It does not matter if
    there is one character or 100 in the database field for the variable.

    Suva1 Guest

  4. #4

    Default Re: LEN of SELECT variable always the same?

    After checking just the LEN it appears to now be reporting correctly without
    the quotes. This appears to be the solution, it's the simple things...

    I'll update this as the correct answer after updating everything tomorrow to
    be sure it's working correctly.

    Thanks for your help!

    Suva1 Guest

Similar Threads

  1. Using a variable as a SELECT field
    By tjIII in forum Coldfusion Database Access
    Replies: 3
    Last Post: October 29th, 10:30 PM
  2. How to SELECT DatePart as a new Variable
    By Gahiggidy in forum Macromedia ColdFusion
    Replies: 0
    Last Post: June 30th, 06:25 PM
  3. how to use a variable into a select?
    By Mich in forum ASP Database
    Replies: 11
    Last Post: November 8th, 03:15 PM
  4. variable select statement
    By Karzy in forum PHP Development
    Replies: 2
    Last Post: October 4th, 01:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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