Ask a Question related to Coldfusion Database Access, Design and Development.
-
TimMcGeary #1
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# #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
-
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... -
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... -
output of a <cfquery>
I have a pretty straightforward query - please see code attached. The parameters passed to query are -... -
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... -
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 =... -
mxstu #2
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
-
TimMcGeary #3
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
-
mxstu #4
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



Reply With Quote

