EasyCFM.COM ColdFusion Forums / Coding Help! / cfloop table - Identifying specific rows

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: cfloop table - Identifying specific rows

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

satellite
07-01-2004 @ 11:11 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 5
Joined: Jun 2004

I am reading document names from a database and displaying the document names within a table.  This table is generated in a cfloop, as the number of documents being read changes.  Each document has an accept and reject radio button:


<table>
   <tr>
      <td>Document ID</td>
      <td>Document Name</td>
      <td>Documetn Dept</td>
      <td>Accept</td>
      <td>Reject</td>
      <td>Reason if Rejecting</td>
   </tr>
   <cfloop query = "getDocs">
   <tr>
      <td><cfoutput>#id#</cfoutput></td>
      <td><a href=UrlOfDocFolder/#fileName#>
              #docName#</a></cfoutput></td>
      <td><cfoutput>#department#</cfoutput></td>
      <td><input type="radio"name="yn"
         value="Accept#id#" >
Accept</font></td>
      <td><input type="radio" name="yn"
         value="Reject#id#" >
Reject</font></td>
      <td><input type="text" name="rejectedBecause">
      </td>
   </tr>
   </cfloop>
</table>


In the action page i am able to find out wheter the accept or reject button was clicked.  However i am unable to find out which document the accept or reject button was related to.  This results in all documents being accepted or rejected, which isnt what i want.  I need to know the document that selected radio button reffers to.  Any help on this would be appreciated.

Webmaster
07-01-2004 @ 11:21 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

you need to differentiate the Items accordingly..

By this I mean...

You have this: <input type="radio" name="yn"         value="Reject#id#">

But that would mean that all items on the page are named: yn

So in reality you can ONLY do one selection for ALL items on the page... instead it should be:
<input type="radio" name="yn#id#" value="Reject">

From the looks of things, you have the right idea.. just put the ID in the wrong place Wink  try changing it and let me know if you have any further questions!

Thanks,
Pablo Varando
Team Macromedia Member
=====================================================

satellite
07-02-2004 @ 6:42 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 5
Joined: Jun 2004

Thank you, ive tried out what you said.  I see now what you meant about the names, no documeent was unique the way i was doing it.  
   However i do have another problem now.  In the action page i dont know how to extract two pieces of information from the radio button names.  I need to be able to find out if the radio button is called AcceptX or RejectX (where x is the document number), and i also need to know the value of X. I have been trying to use the SpanInclude and SpanExclude functions, but im unsucessful it.  

This is an idea for finding out if the radio button was the Reject button:
     
<cfif Form.yn#id# IS "Reject#id#">

This was an idea for finding out the document number:

<cfset textId = #SpanExcluding(Form.yn, "Reject")#

Neither of these ideas are currently working.
If you have any ideas for this, please let me know.

kene
07-02-2004 @ 3:59 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 180
Joined: Sep 2003

You can get the ID value from each radio button by doing something like the following.

<cfloop index="fName" list="#form.FieldNames#">
     <cfif #left(fName, 2)# IS "YN">
          <cfset idValue = #RemoveChars(fName, 1, 2)#>

<!--- a query action would go in here --->
</cfif>
</cfloop>

Actually using a checkbox for "accept" would be easier than a radio button pair since the formfield list you get above would only include checked items. If the checkbox value exists, they accept that document. Otherwise they are rejecting that item. You have all the ID values for accepted documents and none for the rejected documents. Hope that makes sense.

If you need additional help, let me know.


Website Designed and Developed by Pablo Varando.