如何获得该特定记录的currentRow?

时间:2014-06-13 18:44:36

标签: coldfusion

我正在尝试在提交表单时获取当前记录 对于那个特定的行。 当我转储以查看表单获取的内容它仍然获取所有行 在查询中。 这是我点击'submit1'时获得的,(我裁剪图像) enter image description here Mush2和Mush3具有确切的记录数。

如何获取该特定记录的currentRow? 为了得到它,它只会得到我提交的记录的txtresponseid [x]。

<form method="post" action="cse_execoffice_pending.cfm" name="review_comments">
<cfoutput>
<input type="hidden" name="txtApprovedBy" value="#GetCurrentUser.emp_id#">
<!-- count the records that come in from the pending -->
<input type="hidden" name="txtTotalRecords" value="#Mush2.CurrentRow#">
</cfoutput>
<cfoutput query="Mush3">

        <div class="comments_approvaldecision">
            <p>

            <CFDUMP VAR=#response_id#>
            <input type="hidden" name="txtResponseID#CurrentRow#" value="#response_id#">
            <input type="radio" name="execoffice_status#CurrentRow#" id="approve#CurrentRow#" value="1" checked="checked"> <label for="approve#CurrentRow#">Approve</label><br>
            <input type="radio" name="execoffice_status#CurrentRow#" id="deny#CurrentRow#" value="2"> <label for="deny#CurrentRow#">Deny</label>
            </p>
            <p>&nbsp;</p>
            <p>
            <input type="radio" name="star#mush3.CurrentRow#" id="givestar#CurrentRow#" value="0" checked="checked"> <label for="givestar#CurrentRow#"></i> Give Star!</label><br>
            <input type="radio" name="star#mush3.CurrentRow#" id="denystar#CurrentRow#" value="1"> <label for="denystar#CurrentRow#"></i> No Star</label>
            </p>
        </div>

        <div class="clearfloat<cfif (#commentpositive# eq '')> hideempty</cfif>"><img src="positive.gif" width="10" height="10"> Positive Comments:<br>
        <cfset reReplaceCommentpositive = reReplace(commentpositive, '<br>', '', 'ALL')>
        <textarea rows="3" name="txtCommentPositive#CurrentRow#">#reReplaceCommentpositive#</textarea></div>
        <div class="clearfloat<cfif (#commentnegative# eq '')> hideempty</cfif>"><img src="negative.gif" width="10" height="10"> Negative Comments:<br>
        <cfset reReplaceCommentnegative = reReplace(commentnegative, '<br>', '', 'ALL')>
        <textarea rows="3" name="txtCommentNegative#CurrentRow#">#reReplaceCommentnegative#</textarea></div>

    <input type="submit" name="Submit1" value="Submit">
</cfoutput>

<p><input type="submit" name="Submit" value="Submit"></p>
</form>

</cfif><!--- /cfif FormSubmit eq "FormNotSubmitted" --->
<cfdump var="#form#">

2 个答案:

答案 0 :(得分:2)

目前,您的网页只是一个大表单,在表单中循环mush3

要单独提交每个,请在循环的每次迭代中创建并结束<form>

<cfoutput query="Mush3">
    <form method="post" action="cse_execoffice_pending.cfm" name="review_comments#CurrentRow#">

    ... form data....
    <input type="submit" name="Submit1" value="Submit#CurrentRow#">
    </form>
</cfoutput>

答案 1 :(得分:2)

我最后一次做这样的事情,我使用了以下方法。首先,在我的表单上,我将当前值包含为隐藏字段。请注意,字段名称包含缩进字符,问题中的字段名称也是如此。

<cfoutput query="ExistingRecords">
<tr align="left">
<th>Name</th>
<td>
<input type="hidden" name="OldName#doctorid#" value="#name#" />
<cfinput type="text" 
name="name#doctorid#" 
value="#name#" size="50" onChange="this.value=Trim(this.value);" maxlength="100">
</td>
</tr>
</cfoutput>

然后我确定要更新的记录。

<cfloop list="#form.fieldnames#" index="ThisElement">
<cfscript>
UpdateRecord = false;

if (some stuff about new records) {
} // new name??

else if (left(ThisElement, 7) == "oldname"){
ThisId = RemoveChars(ThisElement, 1, 7);
ThisOldName = form["OldName" & ThisId];
ThisName = safetext(form["Name" & ThisId]);

if (Compare(ThisName, ThisOldName) ) 
UpdateRecord = true;
}  // oldname?

仍在循环中,如果合适,我会更新

<cfif UpdateRecord>
<cfquery datasource="#dsn#">
update doctor
set name = <cfqueryparam cfsqltype="cf_sql_varchar" value="#ThisName#">

where doctorid = <cfqueryparam cfsqltype="cf_sql_integer" value="#ThisId#">
</cfquery>
</cfif>

</cfloop>  <!--- form fields --->

我使用过类似但不完全相同的其他方法。所有这些都遍历表单字段列表并标识&#34; ThisId&#34;。

顺便说一句,safetext是cflib.org上的一个函数,你可能会发现它很有用。