Im runnign a cfquery to get images from my database, Then I cfoutput them on a simple table in rows of six. I aded a form tag to allow the user to update the caption assosiated with the image. The probelm is, how do I make each form unique so that when a user updates one form it dose not try to submit all of the forms. I tried using a unique name for each form by naming each form a different id number assosciated withe the image being updated, but I don't seem to get any defined form variables when I hit submit. I used cfdump to dump the form variables and nothing shows up. If I look for the input tag "pic_cation" then I can see the form variables but what happen is all the forms on the page will take on the value for any value entered into any form text field. Intereting thing is that there are 8 images with eight forms. If I use a 1 as a test value and submit the form, (then cfoutput the form variable pic_caption) the first cfoutput will show 8 "1's" the second 7, then 6 and so on and so forth down to 1 "1" I'm having trouble with the code in blue. Code: <!---PICTURE QUERY---> <cfquery datasource="#application.datasource#" name="gallery"> SELECT PICS_ID, PICS_PATH, PICS_THUMB_PATH, PICS_URL, PICS_THUMB_URL, PICS_CAPTION, PICS_TYPE, PICS_DATE FROM NA_PICS WHERE PICS_TYPE = 'GALLERY' ORDER BY PICS_DATE DESC </cfquery> <!---OUTPUT TABLE---> <table> <cfoutput query="gallery"> <cfif gallery.currentrow mod 5 eq 1> <tr> </cfif> <td style="padding:30px 30px 0px 0px;"> <a href="javascript: if (confirm('Delete Picture?')) { window.location.href='deletepicture.cfm?url.pics_id=#PICS_ID#' } else { void('') }; ">DELETE</a> <br/><img style="border:0px;" src="#pics_thumb_url#" /><br/> <div style="padding:5px 0px 0px 0px;"> [COLOR="royalblue"]<cfif IsDefined('form.pics_caption')> <cfoutput>#form.pics_caption#</cfoutput></cfif><br/> <form action="gallery.cfm" method="post" name="#pics_id#" > <input type="text" name="#pics_id#" value="#pics_caption#" size="12"> <br/><br/><input type="submit" nave="#pics_id#" value="Save Caption"> </form>[/COLOR] </div> </td> <cfif gallery.currentrow mod 5 eq 0> </tr> </cfif> </cfoutput> </table> Code (markup): Maybe I need a different approch all together. Thanks for any input. James
I'm not really sure how you're getting those results. I don't even see a form field named form.pics_caption ... If you use separate <form> tags, they're automatically unique. Notice how the attached produces only pics_id and caption value when the form is submitted? <!--- sample query for testing ---> <cfset gallery = QueryNew("")> <cfset queryAddColumn(gallery, "pics_id", listToArray("1,2,3,4"))> <cfset queryAddColumn(gallery, "pics_caption", listToArray("Caption1,Caption2,Caption3,Caption4"))> <!--- if form was submitted, show values ---> <cfif structKeyExists(FORM, "submitButton")> <cfoutput> form.pics_id = #pics_id#<br> form.pics_caption = #pics_caption#<br> </cfoutput> </cfif> <cfoutput query="gallery"> <form action="gallery.cfm" method="post" name="#pics_id#" > pics_id=#pics_id# <input type="hidden" name="pics_id" value="#pics_id#" size="12"> <input type="text" name="pics_caption" value="#pics_caption#" size="12"> <input type="submit" name="submitButton" value="Save Caption"> </form><br> </cfoutput> Code (markup):