1

I have a form that is submitted, it show all the comments from a table which are showing properly and able to submit good. I would like to add ( if possible ) a submit button for EVERY comment that display. In the original code below it has one submit button, so when a user click on it it will submit all comments. I would like it to be a option to have 'submit all' button and 'submit' individual comment, if this is possible?

What would be the best way to approced this?

<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>
0

1 Answer 1

3

Yes you can...Here is a simple example of using buttons to do different things (in the same form).

<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>

More:

You asked if you can submit a record without spinning through all the others. Right?

In that case you need to wrap your cfoutput tag around your form. You will spawn many forms. Notice that I have a unique name for each form when I loop over the recurs using your currentrow as a unique-ifyer :) I rendered your form to a basic example so you can see without all that other stuff...

<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>

If you take this basic example. Add a

<cfdump var="#form#"> 

You will see you have a unique set of form data for only one form / currentrow.

And I believe that is what you are looking for, yes?

4
  • i see but can it be done for each individual comment, like it will be submitter for each comment or submit all Jun 10, 2014 at 19:57
  • @yes i was asking if i could add a record without spinning through all the others, and it the end have a submit that you can submit them all Jun 10, 2014 at 21:57
  • with all the changes , gives me erros Jun 11, 2014 at 23:38
  • Refactoring code is not fun. I assume the code that processes the form is expecting something different than what you are feeding it? I would approach the problem like this. Get your cfoutput loop to spawn the individual forms in a new page. Inspect the form and determine if all the variables look correct (view the clientside source). Populating properly? Then make a new form processing page that matches the data you are trying to submit. If you can create a new question with your new form and form process code fresh eyes can make suggestions. Jun 12, 2014 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.