cfquery output duplicatig a cfset variable

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

  1. #1

    Default cfquery output duplicatig a cfset variable

    I am experiencing a weird duplication of a cfset variable that I am trying to
    use in a form as a hidden input element. I am dynamically building a table via
    a cfquery output of records that need to be given a new status when selected.
    This new status is set as a cfset variable. But this variable is being changed
    based on how many records are being outputted. If there are five records, my
    variable newstatus is being sent as a hidden input this way:

    record 1 newstatus=8
    record 2 newstatus=88
    record 3 newstatus=888
    record 4 newstatus=8888
    record 5 newstatus=88888

    Why is this happening and how can I change it? I know this is not exactly a
    database problem, but I think the database output is affecting this variable.
    Here is the code. The <cfset> and <cfquery> are on the top of the page, and
    the <form> and <output> is done with in a table in the body:



    <cfset newstatus = "8">
    <cfquery name="to_lmc" datasource="storage">
    SELECT r.request_id, r.request_time, r.title, r.author, r.callnum,
    rby.firstname, rby.lastname, rby.LIN, rby.email, r.requestor_id
    FROM (status s INNER JOIN requests r ON s.request_id = r.request_id)
    INNER JOIN requestors rby ON r.requestor_id = rby.requestor_id
    WHERE s.status_id = 6 OR s.status_id = 7
    </cfquery>

    <cfif to_lmc.recordcount gt 0>
    <cfoutput query="to_lmc">
    <tr><form action="item_received.cfm" method="post">
    <td align="center">#request_id#<input name="request_id" type="hidden"
    value="#request_id#"></td>
    <td>#request_time#</td>
    <td>#firstname#&nbsp;#lastname#</td>
    <td>#LIN#</td>
    <td>#email#</td>
    <td>#title#</td>
    <td>#author#</td>
    <td>#callnum#</td>
    <td><input name="status_id" type="hidden"
    value="<cfoutput>#newstatus#</cfoutput>">
    <button>Mark Completed</button></td>
    </form>
    </tr>
    </cfoutput>

    TimMcGeary Guest

  2. Similar Questions and Discussions

    1. Output from different datasource in cfquery statement
      i've make 2 cfquery statements. one refers to datasource DatStudent and another one refers to datasource DatModul. in coldfusion admin, DatStudent...
    2. Using form variable in a CFQuery
      In my Access database are two tables - tblreg_info and tblcourse_description. They are linked via a primary key, ref_no, in the course_description...
    3. output of a <cfquery>
      I have a pretty straightforward query - please see code attached. The parameters passed to query are -...
    4. Output from Cfquery
      I have some pl/sql I want to run in my cfquery. I'd like to get the output from the cfquery The cfquery is calling a function. <cfquery...
    5. output variable to txt file
      I made a flash program that finds prime numbers. These prime numbers are put into a string which gets longer and longer vPrimeString =...
  3. #2

    Default Re: cfquery output duplicatig a cfset variable

    I think it is because of the nested cfoutput tags. You don't need the extra
    cfoutput around the hidden form field since the entire form is contained within
    an cfoutput query="...." statement



    <!--- removed extra cfoutput around hidden value --->
    <cfif to_lmc.recordcount gt 0>
    <cfoutput query="to_lmc">
    <tr><form action="item_received.cfm" method="post">
    ......
    <td><input name="status_id" type="hidden" value="#newstatus#">
    <button>Mark Completed</button></td>
    </form>
    </tr>
    </cfoutput>

    mxstu Guest

  4. #3

    Default Re: cfquery output duplicatig a cfset variable

    this show worked, but I don't understand why a <cfoutput> tag isn't needed
    since this variable is not part of the query output, but rather from a <cfset>.
    Does CF just default to a general <cfoutput> if a #variable# is not found in
    the query output?

    TimMcGeary Guest

  5. #4

    Default Re: cfquery output duplicatig a cfset variable

    Originally posted by: TimMcGeary
    Does CF just default to a general <cfoutput> if a #variable# is not found in
    the query output?

    Sort of. Using cfoutput query="..." doesn't mean only output values in the
    specified query. It is more like saying *include* ...or make accessible... the
    query values in this cfoutput operation. You are still using cfoutput which
    always evaluates all variables surrounded by pound signs.




    mxstu 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