我可以有多个提交几乎执行相同的操作吗?

时间:2014-06-10 18:51:00

标签: coldfusion

我有一个提交的表单,它显示表中的所有注释 哪些是正确显示并能够提交好的。 我想添加(如果可能的话)每个评论的提交按钮 显示。在下面的原始代码中它有一个提交按钮,所以当一个用户 点击它将提交所有评论。 我希望能够提供所有'按钮和 '提交'个人评论,如果可能的话?

最好的方法是什么?

<form method="post" action="cse_execoffice_pending.cfm" name="review_comments">
<cfoutput>
<input type="hidden" name="txtApprovedBy" value="#GetCurrentUser.emp_id#">
<input type="hidden" name="txtTotalRecords" value="#Mush2.Recordcount#">
</cfoutput>
<cfoutput query="Mush3">
    <hr>
        <div class="comments_approvaldecision">
            <p>
            <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>
        </div>

        <div class="comments_pendingapproval">

        <div class="clearfloat<cfif (#commentpositive# eq '')> hideempty</cfif>"> 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>"> Negative Comments:<br>
        <cfset reReplaceCommentnegative = reReplace(commentnegative, '<br>', '', 'ALL')>
        <textarea rows="3" name="txtCommentNegative#CurrentRow#">#reReplaceCommentnegative#</textarea></div>


        <table>
        <thead><tr><th>Rating</th><th>Question</th></tr></thead>
        <tbody>
        <cfloop index="i" from="1" to="5">
        <cfset rating = Mush3["rating" & i][Mush3.CurrentRow]>
        <cfset question = Mush3["csedept_question" & i][Mush3.CurrentRow]>
            <tr>
                <td valign="top">
                    <cfif #rating# eq 5></cfif>
                    ........more code ...
                </td>
                <td valign="top">#question#</td>
            </tr>
        </cfloop>
        </tbody>
    </table>

    </div>
</cfoutput>

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

1 个答案:

答案 0 :(得分:3)

是的,你可以......这是一个使用按钮做不同事情的简单例子(以相同的形式)。

<cfif form.action is "insert">
    <!---Insert code here....--->
</cfif>
<cfif form.action eq "update">
    <!---update code here--->
</cfif>
<cfif form.action eq "delete">
    <!---delete code here--->
</cfif>
<form action="">
    <input type="submit" name="action" value="insert">
    <input type="submit" name="action" value="update">
    <input type="submit" name="action" value="delete">
</form>

更多

您询问是否可以提交记录而不会旋转所有其他记录。正确?

在这种情况下,您需要在表单周围包装cfoutput标记。你会产生许多形式。请注意,当我使用您的currentrow作为unique-ifyer循环重复时,每个表单都有一个唯一的名称:)我将您的表单呈现为一个基本示例,这样您就可以看到没有其他所有内容......

<cfoutput query="Mush3">
<form method="post" action="" name="comments#CurrentRow#">
<input type="hidden" name="txtApprovedBy" value="#GetCurrentUser.emp_id#">
<input type="hidden" name="txtTotalRecords" value="#Mush2.Recordcount#">
<input type="hidden" name="txtResponseID#CurrentRow#" value="#response_id#">
Approve or Deny:<br>
<label for="approve#CurrentRow#">
<input type="radio" name="execoffice_status#CurrentRow#" id="approve#CurrentRow#" value="1" checked="checked">Approve</label> 
<label for="deny#CurrentRow#">
<input type="radio" name="execoffice_status#CurrentRow#" id="deny#CurrentRow#" value="2">Deny</label> 
<br>
Positive comment:<br>
<textarea rows="3" name="txtCommentPositive#CurrentRow#">#reReplaceCommentpositive#</textarea></div>
<br>
Negative comment:<br>
<textarea rows="3" name="txtCommentNegative#CurrentRow#">#reReplaceCommentnegative#</textarea></div>
<br>
<input type="submit" name="Submit" value="Submit">
</form>
</cfoutput>

如果你采用这个基本的例子。添加

<cfdump var="#form#"> 

您将看到只有一种表格/ currentrow的唯一一组表格数据。

我相信这就是你要找的,是吗?